Skip to content

Commit 1341782

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 ca33d5e commit 1341782

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
@@ -2017,32 +2017,18 @@ function initSearch(rawSearchIndex) {
20172017
if (unboxingDepth >= UNBOXING_LIMIT) {
20182018
return false;
20192019
}
2020-
if (row.bindings.size === 0 && elem.bindings.size === 0) {
2021-
if (elem.id < 0 && mgens === null) {
2022-
return row.id < 0 || checkIfInList(
2023-
row.generics,
2024-
elem,
2025-
whereClause,
2026-
mgens,
2027-
unboxingDepth + 1,
2028-
);
2029-
}
2030-
if (row.id > 0 && elem.id > 0 && elem.pathWithoutLast.length === 0 &&
2031-
typePassesFilter(elem.typeFilter, row.ty) && elem.generics.length === 0 &&
2032-
// special case
2033-
elem.id !== typeNameIdOfArrayOrSlice && elem.id !== typeNameIdOfTupleOrUnit
2034-
&& elem.id !== typeNameIdOfHof
2035-
) {
2036-
return row.id === elem.id || checkIfInList(
2037-
row.generics,
2038-
elem,
2039-
whereClause,
2040-
mgens,
2041-
unboxingDepth,
2042-
);
2043-
}
2020+
if (row.id > 0 && elem.id > 0 && elem.pathWithoutLast.length === 0 &&
2021+
row.generics.length === 0 && elem.generics.length === 0 &&
2022+
row.bindings.size === 0 && elem.bindings.size === 0 &&
2023+
// special case
2024+
elem.id !== typeNameIdOfArrayOrSlice &&
2025+
elem.id !== typeNameIdOfHof &&
2026+
elem.id !== typeNameIdOfTupleOrUnit
2027+
) {
2028+
return row.id === elem.id && typePassesFilter(elem.typeFilter, row.ty);
2029+
} else {
2030+
return unifyFunctionTypes([row], [elem], whereClause, mgens, null, unboxingDepth);
20442031
}
2045-
return unifyFunctionTypes([row], [elem], whereClause, mgens, null, unboxingDepth);
20462032
}
20472033

20482034
/**

0 commit comments

Comments
 (0)