about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2021-03-05 11:20:31 -0700
committerMichael Howell <michael@notriddle.com>2021-03-05 11:20:31 -0700
commit0571bc42637a9f07c4efe7669c48898d6cc8e25e (patch)
treeb127516148f59878a62e865a6f6fee3fc613ffd2 /src
parent8fd946c63a6c3aae9788bd459d278cb2efa77099 (diff)
downloadrust-0571bc42637a9f07c4efe7669c48898d6cc8e25e.tar.gz
rust-0571bc42637a9f07c4efe7669c48898d6cc8e25e.zip
Use substrings instead of split to grab enum variant paths
Both versions are about equally readable, but this version avoids scanning
the entire path and building an intermediate array (`split()` in Rust is
a lazy iterator, but not in JavaScript).
Diffstat (limited to 'src')
-rw-r--r--src/librustdoc/html/static/main.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index c9b8100fd03..d5071cec0c8 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -1548,9 +1548,9 @@ function defocusSearchBar() {
                 } else if (type === "structfield" && parentType === "variant") {
                     // Structfields belonging to variants are special: the
                     // final path element is the enum name.
-                    var splitPath = item.path.split("::");
-                    var enumName = splitPath.pop();
-                    path = splitPath.join("::");
+                    var enumNameIdx = item.path.lastIndexOf("::");
+                    var enumName = item.path.substr(enumNameIdx + 2);
+                    path = item.path.substr(0, enumNameIdx);
                     displayPath = path + "::" + enumName + "::" + myparent.name + "::";
                     anchor = "#variant." + myparent.name + ".field." + name;
                     pageType = "enum";