Skip to content

Commit

Permalink
Auto merge of rust-lang#80569 - notriddle:patch-3, r=jyn514
Browse files Browse the repository at this point in the history
Use Array.prototype.filter instead of open-coding

Part of rust-lang#79052, originally suggested in rust-lang#79052 (comment) by `@jyn514`

Besides making main.js smaller (always a plus), this also performs better by using the optimized filter implementation in your browser's JavaScript engine (according to `@GuillaumeGomez,` an 84% performance improvement).
  • Loading branch information
bors committed Jan 1, 2021
2 parents 206ee1e + a3958d0 commit 17eec14
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,13 +667,7 @@ function defocusSearchBar() {
results = {}, results_in_args = {}, results_returned = {},
split = valLower.split("::");

var length = split.length;
for (var z = 0; z < length; ++z) {
if (split[z] === "") {
split.splice(z, 1);
z -= 1;
}
}
split = split.filter(function(segment) { return segment !== ""; });

function transformResults(results, isType) {
var out = [];
Expand Down

0 comments on commit 17eec14

Please sign in to comment.