about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/html/static/main.js21
-rw-r--r--src/tools/rustdoc-js/tester.js3
2 files changed, 14 insertions, 10 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index f2e62ee7b6b..80dc6b923f6 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -219,6 +219,15 @@ function hideThemeButtonState() {
     var titleBeforeSearch = document.title;
     var searchTitle = null;
 
+    function removeEmptyStringsFromArray(x) {
+        for (var i = 0, len = x.length; i < len; ++i) {
+            if (x[i] === "") {
+                x.splice(i, 1);
+                i -= 1;
+            }
+        }
+    }
+
     function clearInputTimeout() {
         if (searchTimeout !== null) {
             clearTimeout(searchTimeout);
@@ -756,7 +765,7 @@ function hideThemeButtonState() {
                 results = {}, results_in_args = {}, results_returned = {},
                 split = valLower.split("::");
 
-            split = split.filter(function(segment) { return segment !== ""; });
+            removeEmptyStringsFromArray(split);
 
             function transformResults(results, isType) {
                 var out = [];
@@ -1338,17 +1347,11 @@ function hideThemeButtonState() {
                 var valGenerics = extractGenerics(val);
 
                 var paths = valLower.split("::");
-                var j;
-                for (j = 0, len = paths.length; j < len; ++j) {
-                    if (paths[j] === "") {
-                        paths.splice(j, 1);
-                        j -= 1;
-                    }
-                }
+                removeEmptyStringsFromArray(paths);
                 val = paths[paths.length - 1];
                 var contains = paths.slice(0, paths.length > 1 ? paths.length - 1 : 1);
 
-                var lev;
+                var lev, j;
                 for (j = 0; j < nSearchWords; ++j) {
                     ty = searchIndex[j];
                     if (!ty || (filterCrates !== undefined && ty.crate !== filterCrates)) {
diff --git a/src/tools/rustdoc-js/tester.js b/src/tools/rustdoc-js/tester.js
index c21277de335..a551a97bda5 100644
--- a/src/tools/rustdoc-js/tester.js
+++ b/src/tools/rustdoc-js/tester.js
@@ -264,7 +264,8 @@ function loadMainJsAndIndex(mainJs, searchIndex, storageJs, crate) {
     // execQuery last parameter is built in buildIndex.
     // buildIndex requires the hashmap from search-index.
     var functionsToLoad = ["buildHrefAndPath", "pathSplitter", "levenshtein", "validateResult",
-                           "handleAliases", "getQuery", "buildIndex", "execQuery", "execSearch"];
+                           "handleAliases", "getQuery", "buildIndex", "execQuery", "execSearch",
+                           "removeEmptyStringsFromArray"];
 
     ALIASES = {};
     finalJS += 'window = { "currentCrate": "' + crate + '", rootPath: "../" };\n';