Skip to content

Commit 27db688

Browse files
Clean up JS files code a bit
1 parent 26c9868 commit 27db688

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

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

+6-11
Original file line numberDiff line numberDiff line change
@@ -463,11 +463,10 @@ function initSearch(rawSearchIndex) {
463463
* @param {ParserState} parserState
464464
*/
465465
function parseInput(query, parserState) {
466-
let c, before;
467466
let foundStopChar = true;
468467

469468
while (parserState.pos < parserState.length) {
470-
c = parserState.userQuery[parserState.pos];
469+
const c = parserState.userQuery[parserState.pos];
471470
if (isStopCharacter(c)) {
472471
foundStopChar = true;
473472
if (isSeparatorCharacter(c)) {
@@ -506,7 +505,7 @@ function initSearch(rawSearchIndex) {
506505
}
507506
throw new Error(`Expected \`,\`, \` \`, \`:\` or \`->\`, found \`${c}\``);
508507
}
509-
before = query.elems.length;
508+
const before = query.elems.length;
510509
getNextElem(query, parserState, query.elems, false);
511510
if (query.elems.length === before) {
512511
// Nothing was added, weird... Let's increase the position to not remain stuck.
@@ -515,7 +514,6 @@ function initSearch(rawSearchIndex) {
515514
foundStopChar = false;
516515
}
517516
while (parserState.pos < parserState.length) {
518-
c = parserState.userQuery[parserState.pos];
519517
if (isReturnArrow(parserState)) {
520518
parserState.pos += 2;
521519
// Get returned elements.
@@ -1940,7 +1938,6 @@ function initSearch(rawSearchIndex) {
19401938
*/
19411939
const searchWords = [];
19421940
const charA = "A".charCodeAt(0);
1943-
let i, word;
19441941
let currentIndex = 0;
19451942
let id = 0;
19461943

@@ -2035,7 +2032,7 @@ function initSearch(rawSearchIndex) {
20352032
// convert `rawPaths` entries into object form
20362033
// generate normalizedPaths for function search mode
20372034
let len = paths.length;
2038-
for (i = 0; i < len; ++i) {
2035+
for (let i = 0; i < len; ++i) {
20392036
lowercasePaths.push({ty: paths[i][0], name: paths[i][1].toLowerCase()});
20402037
paths[i] = {ty: paths[i][0], name: paths[i][1]};
20412038
}
@@ -2049,16 +2046,14 @@ function initSearch(rawSearchIndex) {
20492046
// faster analysis operations
20502047
len = itemTypes.length;
20512048
let lastPath = "";
2052-
for (i = 0; i < len; ++i) {
2049+
for (let i = 0; i < len; ++i) {
2050+
let word = "";
20532051
// This object should have exactly the same set of fields as the "crateRow"
20542052
// object defined above.
20552053
if (typeof itemNames[i] === "string") {
20562054
word = itemNames[i].toLowerCase();
2057-
searchWords.push(word);
2058-
} else {
2059-
word = "";
2060-
searchWords.push("");
20612055
}
2056+
searchWords.push(word);
20622057
const row = {
20632058
crate: crate,
20642059
ty: itemTypes.charCodeAt(i) - charA,

src/librustdoc/html/static/js/source-script.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ function createSourceSidebar() {
117117
sidebar.appendChild(title);
118118
Object.keys(sourcesIndex).forEach(key => {
119119
sourcesIndex[key][NAME_OFFSET] = key;
120-
hasFoundFile = createDirEntry(sourcesIndex[key], sidebar, "",
121-
hasFoundFile);
120+
hasFoundFile = createDirEntry(sourcesIndex[key], sidebar, "", hasFoundFile);
122121
});
123122

124123
container.appendChild(sidebar);

0 commit comments

Comments
 (0)