rustdoc-search: simplify the checkTypes fast path

This reduces code size while still matching the common case
for plain, concrete types.
This commit is contained in:
Michael Howell 2024-09-24 11:04:04 -07:00
parent 488d5b0d8e
commit 2cc1c0c39a

View File

@ -2727,33 +2727,18 @@ class DocSearch {
if (unboxingDepth >= UNBOXING_LIMIT) {
return false;
}
if (row.bindings.size === 0 && elem.bindings.size === 0) {
if (elem.id < 0 && mgens === null) {
return row.id < 0 || checkIfInList(
row.generics,
elem,
whereClause,
mgens,
unboxingDepth + 1,
);
}
if (row.id > 0 && elem.id > 0 && elem.pathWithoutLast.length === 0 &&
typePassesFilter(elem.typeFilter, row.ty) && elem.generics.length === 0 &&
// special case
elem.id !== this.typeNameIdOfArrayOrSlice
&& elem.id !== this.typeNameIdOfTupleOrUnit
&& elem.id !== this.typeNameIdOfHof
) {
return row.id === elem.id || checkIfInList(
row.generics,
elem,
whereClause,
mgens,
unboxingDepth,
);
}
if (row.id > 0 && elem.id > 0 && elem.pathWithoutLast.length === 0 &&
row.generics.length === 0 && elem.generics.length === 0 &&
row.bindings.size === 0 && elem.bindings.size === 0 &&
// special case
elem.id !== this.typeNameIdOfArrayOrSlice &&
elem.id !== this.typeNameIdOfHof &&
elem.id !== this.typeNameIdOfTupleOrUnit
) {
return row.id === elem.id && typePassesFilter(elem.typeFilter, row.ty);
} else {
return unifyFunctionTypes([row], [elem], whereClause, mgens, null, unboxingDepth);
}
return unifyFunctionTypes([row], [elem], whereClause, mgens, null, unboxingDepth);
};
/**