Skip to content

Commit 2cc1c0c

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 488d5b0 commit 2cc1c0c

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

Diff for: src/librustdoc/html/static/js/search.js

+11-26
Original file line numberDiff line numberDiff line change
@@ -2727,33 +2727,18 @@ class DocSearch {
27272727
if (unboxingDepth >= UNBOXING_LIMIT) {
27282728
return false;
27292729
}
2730-
if (row.bindings.size === 0 && elem.bindings.size === 0) {
2731-
if (elem.id < 0 && mgens === null) {
2732-
return row.id < 0 || checkIfInList(
2733-
row.generics,
2734-
elem,
2735-
whereClause,
2736-
mgens,
2737-
unboxingDepth + 1,
2738-
);
2739-
}
2740-
if (row.id > 0 && elem.id > 0 && elem.pathWithoutLast.length === 0 &&
2741-
typePassesFilter(elem.typeFilter, row.ty) && elem.generics.length === 0 &&
2742-
// special case
2743-
elem.id !== this.typeNameIdOfArrayOrSlice
2744-
&& elem.id !== this.typeNameIdOfTupleOrUnit
2745-
&& elem.id !== this.typeNameIdOfHof
2746-
) {
2747-
return row.id === elem.id || checkIfInList(
2748-
row.generics,
2749-
elem,
2750-
whereClause,
2751-
mgens,
2752-
unboxingDepth,
2753-
);
2754-
}
2730+
if (row.id > 0 && elem.id > 0 && elem.pathWithoutLast.length === 0 &&
2731+
row.generics.length === 0 && elem.generics.length === 0 &&
2732+
row.bindings.size === 0 && elem.bindings.size === 0 &&
2733+
// special case
2734+
elem.id !== this.typeNameIdOfArrayOrSlice &&
2735+
elem.id !== this.typeNameIdOfHof &&
2736+
elem.id !== this.typeNameIdOfTupleOrUnit
2737+
) {
2738+
return row.id === elem.id && typePassesFilter(elem.typeFilter, row.ty);
2739+
} else {
2740+
return unifyFunctionTypes([row], [elem], whereClause, mgens, null, unboxingDepth);
27552741
}
2756-
return unifyFunctionTypes([row], [elem], whereClause, mgens, null, unboxingDepth);
27572742
};
27582743

27592744
/**

0 commit comments

Comments
 (0)