Skip to content

Commit

Permalink
Use a number for row.id, instead of a string
Browse files Browse the repository at this point in the history
There's no reason for it to be a string, since it's only used for
de-duplicating the results arrays anyhow.
  • Loading branch information
notriddle committed Mar 14, 2021
1 parent 0bfd142 commit f57d715
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand All @@ -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;

Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit f57d715

Please sign in to comment.