Convert this.length to uint32 in Array.prototype.[last]indexOf.

Review URL: http://codereview.chromium.org/3104033

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5340 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
lrn@chromium.org 2010-08-25 12:16:46 +00:00
parent 3c26a55def
commit 16a3419650

View File

@ -953,7 +953,8 @@ function ArrayMap(f, receiver) {
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 @@ function ArrayIndexOf(element, index) {
// 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 ArrayIndexOf(element, index) {
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 {