summary refs log tree commit diff
path: root/src/librustdoc/html/static
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2021-03-12 23:52:46 -0700
committerMichael Howell <michael@notriddle.com>2021-03-13 00:04:04 -0700
commit3f70bfa79cdd94a60e6ed17f7d7c46aab3df1414 (patch)
treeed69b5385be2ba01e81c390eec687a256bc6ae52 /src/librustdoc/html/static
parentd7971e587c948ce943d962073ea3caa7f6830c1d (diff)
downloadrust-3f70bfa79cdd94a60e6ed17f7d7c46aab3df1414.tar.gz
rust-3f70bfa79cdd94a60e6ed17f7d7c46aab3df1414.zip
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.
Diffstat (limited to 'src/librustdoc/html/static')
-rw-r--r--src/librustdoc/html/static/main.js6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 7254f5f465c..6302c357c8f 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -1303,11 +1303,11 @@ function defocusSearchBar() {
 
                     if (searchWords[j].indexOf(split[i]) > -1 ||
                         searchWords[j].indexOf(val) > -1 ||
-                        searchWords[j].replace(/_/g, "").indexOf(val) > -1)
+                        ty.nameWithoutUnderscores.indexOf(val) > -1)
                     {
                         // filter type: ... queries
                         if (typePassesFilter(typeFilter, ty.ty) && results[fullId] === undefined) {
-                            index = searchWords[j].replace(/_/g, "").indexOf(val);
+                            index = ty.nameWithoutUnderscores.indexOf(val);
                         }
                     }
                     if ((lev = levenshtein(searchWords[j], val)) <= MAX_LEV_DISTANCE) {
@@ -1860,6 +1860,7 @@ function defocusSearchBar() {
                     parent: undefined,
                     type: null,
                     id: "",
+                    nameWithoutUnderscores: crate.replace(/_/g, ""),
                 };
                 crateRow.id = generateId(crateRow);
                 searchIndex.push(crateRow);
@@ -1909,6 +1910,7 @@ function defocusSearchBar() {
                         parent: itemParentIdxs[i] > 0 ? paths[itemParentIdxs[i] - 1] : undefined,
                         type: itemFunctionSearchTypes[i],
                         id: "",
+                        nameWithoutUnderscores: itemNames[i].replace(/_/g, ""),
                     };
                     row.id = generateId(row);
                     searchIndex.push(row);