Skip to content

Commit 3f70bfa

Browse files
committed
Eagerly generate the underscore-less name to search on
Basically, it doesn't make sense to generate those things every time you search. That generates a bunch of stuff for the GC to clean up, when, if the user wanted to do another search, it would just need to re-do it again.
1 parent d7971e5 commit 3f70bfa

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/librustdoc/html/static/main.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1303,11 +1303,11 @@ function defocusSearchBar() {
13031303

13041304
if (searchWords[j].indexOf(split[i]) > -1 ||
13051305
searchWords[j].indexOf(val) > -1 ||
1306-
searchWords[j].replace(/_/g, "").indexOf(val) > -1)
1306+
ty.nameWithoutUnderscores.indexOf(val) > -1)
13071307
{
13081308
// filter type: ... queries
13091309
if (typePassesFilter(typeFilter, ty.ty) && results[fullId] === undefined) {
1310-
index = searchWords[j].replace(/_/g, "").indexOf(val);
1310+
index = ty.nameWithoutUnderscores.indexOf(val);
13111311
}
13121312
}
13131313
if ((lev = levenshtein(searchWords[j], val)) <= MAX_LEV_DISTANCE) {
@@ -1860,6 +1860,7 @@ function defocusSearchBar() {
18601860
parent: undefined,
18611861
type: null,
18621862
id: "",
1863+
nameWithoutUnderscores: crate.replace(/_/g, ""),
18631864
};
18641865
crateRow.id = generateId(crateRow);
18651866
searchIndex.push(crateRow);
@@ -1909,6 +1910,7 @@ function defocusSearchBar() {
19091910
parent: itemParentIdxs[i] > 0 ? paths[itemParentIdxs[i] - 1] : undefined,
19101911
type: itemFunctionSearchTypes[i],
19111912
id: "",
1913+
nameWithoutUnderscores: itemNames[i].replace(/_/g, ""),
19121914
};
19131915
row.id = generateId(row);
19141916
searchIndex.push(row);

0 commit comments

Comments
 (0)