Skip to content

Commit 6047b9e

Browse files
committed
rustdoc-search: simplify the checkTypes fast path
This reduces code size while still matching the common case for plain, concrete types.
1 parent fd8d6fb commit 6047b9e

File tree

1 file changed

+11
-25
lines changed

1 file changed

+11
-25
lines changed

src/librustdoc/html/static/js/search.js

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,32 +2015,18 @@ function initSearch(rawSearchIndex) {
20152015
if (unboxingDepth >= UNBOXING_LIMIT) {
20162016
return false;
20172017
}
2018-
if (row.bindings.size === 0 && elem.bindings.size === 0) {
2019-
if (elem.id < 0 && mgens === null) {
2020-
return row.id < 0 || checkIfInList(
2021-
row.generics,
2022-
elem,
2023-
whereClause,
2024-
mgens,
2025-
unboxingDepth + 1,
2026-
);
2027-
}
2028-
if (row.id > 0 && elem.id > 0 && elem.pathWithoutLast.length === 0 &&
2029-
typePassesFilter(elem.typeFilter, row.ty) && elem.generics.length === 0 &&
2030-
// special case
2031-
elem.id !== typeNameIdOfArrayOrSlice && elem.id !== typeNameIdOfTupleOrUnit
2032-
&& elem.id !== typeNameIdOfHof
2033-
) {
2034-
return row.id === elem.id || checkIfInList(
2035-
row.generics,
2036-
elem,
2037-
whereClause,
2038-
mgens,
2039-
unboxingDepth,
2040-
);
2041-
}
2018+
if (row.id > 0 && elem.id > 0 && elem.pathWithoutLast.length === 0 &&
2019+
row.generics.length === 0 && elem.generics.length === 0 &&
2020+
row.bindings.size === 0 && elem.bindings.size === 0 &&
2021+
// special case
2022+
elem.id !== typeNameIdOfArrayOrSlice &&
2023+
elem.id !== typeNameIdOfHof &&
2024+
elem.id !== typeNameIdOfTupleOrUnit
2025+
) {
2026+
return row.id === elem.id && typePassesFilter(elem.typeFilter, row.ty);
2027+
} else {
2028+
return unifyFunctionTypes([row], [elem], whereClause, mgens, null, unboxingDepth);
20422029
}
2043-
return unifyFunctionTypes([row], [elem], whereClause, mgens, null, unboxingDepth);
20442030
}
20452031

20462032
/**

0 commit comments

Comments
 (0)