Skip to content

Commit f1342f3

Browse files
Clean up variables in search.js
1 parent 6f40082 commit f1342f3

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
@@ -2102,8 +2102,6 @@ function initSearch(rawSearchIndex) {
21022102
}
21032103

21042104
function innerRunQuery() {
2105-
let elem, i, nSearchWords, in_returned, row;
2106-
21072105
let queryLen = 0;
21082106
for (const elem of parsedQuery.elems) {
21092107
queryLen += elem.name.length;
@@ -2225,8 +2223,8 @@ function initSearch(rawSearchIndex) {
22252223

22262224
if (parsedQuery.foundElems === 1) {
22272225
if (parsedQuery.elems.length === 1) {
2228-
elem = parsedQuery.elems[0];
2229-
for (i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
2226+
const elem = parsedQuery.elems[0];
2227+
for (let i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
22302228
// It means we want to check for this element everywhere (in names, args and
22312229
// returned).
22322230
handleSingleArg(
@@ -2241,10 +2239,9 @@ function initSearch(rawSearchIndex) {
22412239
}
22422240
} else if (parsedQuery.returned.length === 1) {
22432241
// We received one returned argument to check, so looking into returned values.
2244-
elem = parsedQuery.returned[0];
2245-
for (i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
2246-
row = searchIndex[i];
2247-
in_returned = row.type && unifyFunctionTypes(
2242+
for (let i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
2243+
const row = searchIndex[i];
2244+
const in_returned = row.type && unifyFunctionTypes(
22482245
row.type.output,
22492246
parsedQuery.returned,
22502247
row.type.where_clause
@@ -2262,7 +2259,7 @@ function initSearch(rawSearchIndex) {
22622259
}
22632260
}
22642261
} else if (parsedQuery.foundElems > 0) {
2265-
for (i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
2262+
for (let i = 0, nSearchWords = searchWords.length; i < nSearchWords; ++i) {
22662263
handleArgs(searchIndex[i], i, results_others);
22672264
}
22682265
}
@@ -2418,7 +2415,6 @@ function initSearch(rawSearchIndex) {
24182415
const extraClass = display ? " active" : "";
24192416

24202417
const output = document.createElement("div");
2421-
let length = 0;
24222418
if (array.length > 0) {
24232419
output.className = "search-results " + extraClass;
24242420

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

2431-
length += 1;
2432-
24332427
const link = document.createElement("a");
24342428
link.className = "result-" + type;
24352429
link.href = item.href;
@@ -2477,7 +2471,7 @@ ${item.displayPath}<span class="${type}">${name}</span>\
24772471
"href=\"https://docs.rs\">Docs.rs</a> for documentation of crates released on" +
24782472
" <a href=\"https://crates.io/\">crates.io</a>.</li></ul>";
24792473
}
2480-
return [output, length];
2474+
return [output, array.length];
24812475
}
24822476

24832477
function makeTabHeader(tabNb, text, nbElems) {

0 commit comments

Comments
 (0)