Chromium Code Reviews| Index: Source/devtools/front_end/utilities.js |
| diff --git a/Source/devtools/front_end/utilities.js b/Source/devtools/front_end/utilities.js |
| index 66d9aacc83b5ff9f4aacce4c3fe94eda9bf9612e..d7b3f7d222d7d76b873fac5a5e6b6c60134a5410 100644 |
| --- a/Source/devtools/front_end/utilities.js |
| +++ b/Source/devtools/front_end/utilities.js |
| @@ -374,23 +374,22 @@ Object.defineProperty(Array.prototype, "remove", |
| { |
| /** |
| * @param {!T} value |
| - * @param {boolean=} onlyFirst |
| + * @param {boolean=} firstOnly |
| * @this {Array.<!T>} |
| * @template T |
| */ |
| - value: function(value, onlyFirst) |
| + value: function(value, firstOnly) |
| { |
| - if (onlyFirst) { |
| + if (firstOnly) { |
| var index = this.indexOf(value); |
| if (index !== -1) |
| this.splice(index, 1); |
| return; |
| } |
| - var length = this.length; |
| - for (var i = 0; i < length; ++i) { |
| - if (this[i] === value) |
| - this.splice(i, 1); |
| + for (var pos = this.indexOf(value); pos !== -1; pos = this.indexOf(value, pos + 1)) { |
| + for (var end = pos + 1; end < this.length && this[end] === value; ++end) {} |
| + this.splice(pos, end - pos); |
|
aandrey
2014/03/25 12:04:23
not lgtm.
this is too complex, I think this does n
|
| } |
| } |
| }); |