diff options
| author | Jacob Hoffman-Andrews <github@hoffman-andrews.com> | 2021-05-09 13:49:22 -0700 |
|---|---|---|
| committer | Jacob Hoffman-Andrews <github@hoffman-andrews.com> | 2021-05-11 10:50:09 -0700 |
| commit | f510e412e93958e099334de22de375d26264e767 (patch) | |
| tree | 0b50f04820359fd800ece9a9062296e18ff2a348 /src/librustdoc/html/static/source-script.js | |
| parent | 6fd7a6dc0f5c4c8fd51d57c0f4f795d52481f904 (diff) | |
| download | rust-f510e412e93958e099334de22de375d26264e767.tar.gz rust-f510e412e93958e099334de22de375d26264e767.zip | |
rustdoc: remove explicit boolean comparisons.
For boolean variables it's shorter and more readable to check the value directly, or negate it with `!`. In a couple of cases I reordered an if/else pair because it made the initial `if` statement simpler. Removed unused isType parameter from two functions.
Diffstat (limited to 'src/librustdoc/html/static/source-script.js')
| -rw-r--r-- | src/librustdoc/html/static/source-script.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/librustdoc/html/static/source-script.js b/src/librustdoc/html/static/source-script.js index 42b54e4cc1e..81df5411896 100644 --- a/src/librustdoc/html/static/source-script.js +++ b/src/librustdoc/html/static/source-script.js @@ -44,7 +44,7 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) { if (elem.dirs) { for (i = 0, len = elem.dirs.length; i < len; ++i) { if (createDirEntry(elem.dirs[i], folders, fullPath, currentFile, - hasFoundFile) === true) { + hasFoundFile)) { addClass(name, "expand"); hasFoundFile = true; } @@ -59,8 +59,7 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) { var file = document.createElement("a"); file.innerText = elem.files[i]; file.href = window.rootPath + "src/" + fullPath + elem.files[i] + ".html"; - if (hasFoundFile === false && - currentFile === fullPath + elem.files[i]) { + if (!hasFoundFile && currentFile === fullPath + elem.files[i]) { file.className = "selected"; addClass(name, "expand"); hasFoundFile = true; @@ -72,7 +71,7 @@ function createDirEntry(elem, parent, fullPath, currentFile, hasFoundFile) { children.appendChild(files); parent.appendChild(name); parent.appendChild(children); - return hasFoundFile === true && currentFile.startsWith(fullPath); + return hasFoundFile && currentFile.startsWith(fullPath); } function toggleSidebar() { @@ -116,7 +115,7 @@ function createSidebarToggle() { // This function is called from "source-files.js", generated in `html/render/mod.rs`. // eslint-disable-next-line no-unused-vars function createSourceSidebar() { - if (window.rootPath.endsWith("/") === false) { + if (!window.rootPath.endsWith("/")) { window.rootPath += "/"; } var main = document.getElementById("main"); |
