Skip to content

Commit c76e54c

Browse files
authored
Rollup merge of rust-lang#118886 - GuillaumeGomez:clean-up-search-vars, r=notriddle
Clean up variables in `search.js` While reviewing rust-lang#118402, I saw a few small clean ups that were needed, mostly about variables creation. r? `@notriddle`
2 parents 848bd24 + f1342f3 commit c76e54c

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/librustdoc/html/static/js/search.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -2100,8 +2100,6 @@ function initSearch(rawSearchIndex) {
21002100
}
21012101

21022102
function innerRunQuery() {
2103-
let elem, i, nSearchWords, in_returned, row;
2104-
21052103
let queryLen = 0;
21062104
for (const elem of parsedQuery.elems) {
21072105
queryLen += elem.name.length;
@@ -2227,8 +2225,8 @@ function initSearch(rawSearchIndex) {
22272225

22282226
if (parsedQuery.foundElems === 1) {
22292227
if (parsedQuery.elems.length === 1) {
2230-
elem = parsedQuery.elems[0];
2231-
for (i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
2228+
const elem = parsedQuery.elems[0];
2229+
for (let i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
22322230
// It means we want to check for this element everywhere (in names, args and
22332231
// returned).
22342232
handleSingleArg(
@@ -2243,10 +2241,9 @@ function initSearch(rawSearchIndex) {
22432241
}
22442242
} else if (parsedQuery.returned.length === 1) {
22452243
// We received one returned argument to check, so looking into returned values.
2246-
elem = parsedQuery.returned[0];
2247-
for (i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
2248-
row = searchIndex[i];
2249-
in_returned = row.type && unifyFunctionTypes(
2244+
for (let i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
2245+
const row = searchIndex[i];
2246+
const in_returned = row.type && unifyFunctionTypes(
22502247
row.type.output,
22512248
parsedQuery.returned,
22522249
row.type.where_clause
@@ -2264,7 +2261,7 @@ function initSearch(rawSearchIndex) {
22642261
}
22652262
}
22662263
} else if (parsedQuery.foundElems > 0) {
2267-
for (i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
2264+
for (let i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
22682265
handleArgs(searchIndex[i], i, results_others);
22692266
}
22702267
}
@@ -2420,7 +2417,6 @@ function initSearch(rawSearchIndex) {
24202417
const extraClass = display ? " active" : "";
24212418

24222419
const output = document.createElement("div");
2423-
let length = 0;
24242420
if (array.length > 0) {
24252421
output.className = "search-results " + extraClass;
24262422

@@ -2430,8 +2426,6 @@ function initSearch(rawSearchIndex) {
24302426
const longType = longItemTypes[item.ty];
24312427
const typeName = longType.length !== 0 ? `${longType}` : "?";
24322428

2433-
length += 1;
2434-
24352429
const link = document.createElement("a");
24362430
link.className = "result-" + type;
24372431
link.href = item.href;
@@ -2479,7 +2473,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
24792473
"href=\"https://docs.rs\">Docs.rs</a> for documentation of crates released on" +
24802474
" <a href=\"https://crates.io/\">crates.io</a>.</li></ul>";
24812475
}
2482-
return [output, length];
2476+
return [output, array.length];
24832477
}
24842478

24852479
function makeTabHeader(tabNb, text, nbElems) {

0 commit comments

Comments
 (0)