about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2021-03-14 09:57:37 -0700
committerMichael Howell <michael@notriddle.com>2021-03-14 10:17:20 -0700
commitf57d71533eb6199b04f62bb54c8f19d655d3c824 (patch)
tree675fbec3d7a3faa280440716db85e5f84ae6a67e
parent0bfd1429266518d86d28c29f86c30bca063706f0 (diff)
downloadrust-f57d71533eb6199b04f62bb54c8f19d655d3c824.tar.gz
rust-f57d71533eb6199b04f62bb54c8f19d655d3c824.zip
Use a number for row.id, instead of a string
There's no reason for it to be a string, since it's only used for
de-duplicating the results arrays anyhow.
-rw-r--r--src/librustdoc/html/static/main.js16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 729a1297324..68a7ed9a905 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -1833,18 +1833,12 @@ function defocusSearchBar() {
             showResults(execSearch(query, index, filterCrates));
         }
 
-        function generateId(ty) {
-            if (ty.parent && ty.parent.name) {
-                return itemTypes[ty.ty] + ty.path + ty.parent.name + ty.name;
-            }
-            return itemTypes[ty.ty] + ty.path + ty.name;
-        }
-
         function buildIndex(rawSearchIndex) {
             searchIndex = [];
             var searchWords = [];
             var i;
             var currentIndex = 0;
+            var id = 0;
 
             for (var crate in rawSearchIndex) {
                 if (!hasOwnProperty(rawSearchIndex, crate)) { continue; }
@@ -1866,10 +1860,10 @@ function defocusSearchBar() {
                     desc: rawSearchIndex[crate].doc,
                     parent: undefined,
                     type: null,
-                    id: "",
+                    id: id,
                     nameWithoutUnderscores: nameWithoutUnderscores,
                 };
-                crateRow.id = generateId(crateRow);
+                id += 1;
                 searchIndex.push(crateRow);
                 currentIndex += 1;
 
@@ -1921,10 +1915,10 @@ function defocusSearchBar() {
                         desc: itemDescs[i],
                         parent: itemParentIdxs[i] > 0 ? paths[itemParentIdxs[i] - 1] : undefined,
                         type: itemFunctionSearchTypes[i],
-                        id: "",
+                        id: id,
                         nameWithoutUnderscores: nameWithoutUnderscores,
                     };
-                    row.id = generateId(row);
+                    id += 1;
                     searchIndex.push(row);
                     if (typeof row.name === "string") {
                         var word = row.name.toLowerCase();