Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: Source/devtools/front_end/utilities.js

Issue 212863005: DevTools: Make Array.remove O(N). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 Object.defineProperty(Array.prototype, "remove", 373 Object.defineProperty(Array.prototype, "remove",
374 { 374 {
375 /** 375 /**
376 * @param {!T} value 376 * @param {!T} value
377 * @param {boolean=} firstOnly 377 * @param {boolean=} firstOnly
378 * @this {Array.<!T>} 378 * @this {Array.<!T>}
379 * @template T 379 * @template T
380 */ 380 */
381 value: function(value, firstOnly) 381 value: function(value, firstOnly)
382 { 382 {
383 var index = this.indexOf(value);
384 if (index === -1)
385 return;
383 if (firstOnly) { 386 if (firstOnly) {
384 var index = this.indexOf(value); 387 this.splice(index, 1);
385 if (index !== -1)
386 this.splice(index, 1);
387 return; 388 return;
388 } 389 }
389 390 for (var i = index + 1, n = this.length; i < n; ++i) {
390 for (var i = 0; i < this.length; ++i) { 391 if (this[i] !== value)
391 if (this[i] === value) 392 this[index++] = this[i];
392 this.splice(i--, 1);
393 } 393 }
394 this.length = index;
394 } 395 }
395 }); 396 });
396 397
397 Object.defineProperty(Array.prototype, "keySet", 398 Object.defineProperty(Array.prototype, "keySet",
398 { 399 {
399 /** 400 /**
400 * @return {!Object.<string, boolean>} 401 * @return {!Object.<string, boolean>}
401 * @this {Array.<*>} 402 * @this {Array.<*>}
402 */ 403 */
403 value: function() 404 value: function()
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 this._outgoingCallback(); 1528 this._outgoingCallback();
1528 } 1529 }
1529 } 1530 }
1530 1531
1531 /** 1532 /**
1532 * @param {*} value 1533 * @param {*} value
1533 */ 1534 */
1534 function suppressUnused(value) 1535 function suppressUnused(value)
1535 { 1536 {
1536 } 1537 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698