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

Unified Diff: src/array.js

Issue 614733002: Array.prototype.{reduce, reduceRight}: Wrong order of operations when determining initial value. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove unnneded check (length is zero and 'current' is not defined). Fixed tests. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/array-reduce.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/array.js
diff --git a/src/array.js b/src/array.js
index 44deff7de42c60986741615b1be389f9668dbf85..c50a2926395dd8dcf9009c3e136f89871e363895 100644
--- a/src/array.js
+++ b/src/array.js
@@ -1398,9 +1398,8 @@ function ArrayReduce(callback, current) {
var i = 0;
find_initial: if (%_ArgumentsLength() < 2) {
for (; i < length; i++) {
- current = array[i];
- if (!IS_UNDEFINED(current) || i in array) {
- i++;
+ if (i in array) {
+ current = array[i++];
break find_initial;
}
}
@@ -1435,9 +1434,8 @@ function ArrayReduceRight(callback, current) {
var i = length - 1;
find_initial: if (%_ArgumentsLength() < 2) {
for (; i >= 0; i--) {
- current = array[i];
- if (!IS_UNDEFINED(current) || i in array) {
- i--;
+ if (i in array) {
+ current = array[i--];
break find_initial;
}
}
« no previous file with comments | « no previous file | test/mjsunit/array-reduce.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698