From f57d71533eb6199b04f62bb54c8f19d655d3c824 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Sun, 14 Mar 2021 09:57:37 -0700 Subject: [PATCH] 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. --- src/librustdoc/html/static/main.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 729a129732495..68a7ed9a90537 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();