diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2021-03-05 21:44:44 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-05 21:44:44 +0100 |
| commit | 8dfbc00d277e4aa74f4e8d5639fac8e98c4f3ecf (patch) | |
| tree | 15ef6ef45bce119924b89f462bae3ca7e6dc812f /src | |
| parent | 1a08cb6a36b2c6cad8ffe68e1b819b01d6a1f9c7 (diff) | |
| parent | 0571bc42637a9f07c4efe7669c48898d6cc8e25e (diff) | |
| download | rust-8dfbc00d277e4aa74f4e8d5639fac8e98c4f3ecf.tar.gz rust-8dfbc00d277e4aa74f4e8d5639fac8e98c4f3ecf.zip | |
Rollup merge of #82809 - notriddle:microoptimize-main-js, r=GuillaumeGomez
rustdoc: 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.js | 6 |
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"; |
