Skip to content

Commit 2f937c7

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

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2100,8 +2100,6 @@ function initSearch(rawSearchIndex) {
21002100
}
21012101

21022102
functioninnerRunQuery(){
2103-
letelem,i,nSearchWords,in_returned,row;
2104-
21052103
letqueryLen=0;
21062104
for(constelemofparsedQuery.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+
constelem=parsedQuery.elems[0];
2229+
for(leti=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
}elseif(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(leti=0,nSearchWords=searchWords.length;i<nSearchWords;++i){
2245+
constrow=searchIndex[i];
2246+
constin_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
}elseif(parsedQuery.foundElems>0){
2267-
for(i=0,nSearchWords=searchWords.length;i<nSearchWords;++i){
2264+
for(leti=0,nSearchWords=searchWords.length;i<nSearchWords;++i){
22682265
handleArgs(searchIndex[i],i,results_others);
22692266
}
22702267
}
@@ -2420,7 +2417,6 @@ function initSearch(rawSearchIndex) {
24202417
constextraClass=display ? " active" : "";
24212418

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

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

2433-
length+=1;
2434-
24352429
constlink=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
functionmakeTabHeader(tabNb,text,nbElems){

0 commit comments

Comments
 (0)