Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 leadZero(this.getDate()) + "T" + | 367 leadZero(this.getDate()) + "T" + |
| 368 leadZero(this.getHours()) + | 368 leadZero(this.getHours()) + |
| 369 leadZero(this.getMinutes()) + | 369 leadZero(this.getMinutes()) + |
| 370 leadZero(this.getSeconds()); | 370 leadZero(this.getSeconds()); |
| 371 } | 371 } |
| 372 | 372 |
| 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=} onlyFirst | 377 * @param {boolean=} firstOnly |
| 378 * @this {Array.<!T>} | 378 * @this {Array.<!T>} |
| 379 * @template T | 379 * @template T |
| 380 */ | 380 */ |
| 381 value: function(value, onlyFirst) | 381 value: function(value, firstOnly) |
| 382 { | 382 { |
| 383 if (onlyFirst) { | 383 if (firstOnly) { |
| 384 var index = this.indexOf(value); | 384 var index = this.indexOf(value); |
| 385 if (index !== -1) | 385 if (index !== -1) |
| 386 this.splice(index, 1); | 386 this.splice(index, 1); |
| 387 return; | 387 return; |
| 388 } | 388 } |
| 389 | 389 |
| 390 var length = this.length; | 390 var length = this.length; |
| 391 for (var i = 0; i < length; ++i) { | 391 for (var i = 0; i < length; ++i) { |
| 392 if (this[i] === value) | 392 if (this[i] === value) |
| 393 this.splice(i, 1); | 393 this.splice(i--, 1); |
|
aandrey
2014/03/25 07:42:07
FYI: the "length" is no longer valid after this. I
alph
2014/03/25 11:43:41
Good catch!
Rewrote the code to do a single splice
| |
| 394 } | 394 } |
| 395 } | 395 } |
| 396 }); | 396 }); |
| 397 | 397 |
| 398 Object.defineProperty(Array.prototype, "keySet", | 398 Object.defineProperty(Array.prototype, "keySet", |
| 399 { | 399 { |
| 400 /** | 400 /** |
| 401 * @return {!Object.<string, boolean>} | 401 * @return {!Object.<string, boolean>} |
| 402 * @this {Array.<*>} | 402 * @this {Array.<*>} |
| 403 */ | 403 */ |
| (...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1528 this._outgoingCallback(); | 1528 this._outgoingCallback(); |
| 1529 } | 1529 } |
| 1530 } | 1530 } |
| 1531 | 1531 |
| 1532 /** | 1532 /** |
| 1533 * @param {*} value | 1533 * @param {*} value |
| 1534 */ | 1534 */ |
| 1535 function suppressUnused(value) | 1535 function suppressUnused(value) |
| 1536 { | 1536 { |
| 1537 } | 1537 } |
| OLD | NEW |