Revision: 5340 Author: [email protected] Date: Wed Aug 25 05:16:46 2010 Log: Convert this.length to uint32 in Array.prototype.[last]indexOf.
Review URL: http://codereview.chromium.org/3104033 http://code.google.com/p/v8/source/detail?r=5340 Modified: /branches/bleeding_edge/src/array.js ======================================= --- /branches/bleeding_edge/src/array.js Fri Jun 25 02:28:38 2010 +++ /branches/bleeding_edge/src/array.js Wed Aug 25 05:16:46 2010 @@ -953,7 +953,8 @@ function ArrayIndexOf(element, index) { - var length = this.length; + var length = TO_UINT32(this.length); + if (length == 0) return -1; if (IS_UNDEFINED(index)) { index = 0; } else { @@ -963,13 +964,13 @@ // If index is still negative, search the entire array. if (index < 0) index = 0; } + // Lookup through the array. if (!IS_UNDEFINED(element)) { for (var i = index; i < length; i++) { if (this[i] === element) return i; } return -1; } - // Lookup through the array. for (var i = index; i < length; i++) { if (IS_UNDEFINED(this[i]) && i in this) { return i; @@ -980,7 +981,8 @@ function ArrayLastIndexOf(element, index) { - var length = this.length; + var length = TO_UINT32(this.length); + if (length == 0) return -1; if (%_ArgumentsLength() < 2) { index = length - 1; } else { -- v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev
