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

Unified Diff: src/array.js

Issue 1162043008: Revert of Implement %TypedArray%.prototype.{reduce,reduceRight} (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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 | src/harmony-typedarray.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 467fd99d68a4868b49ebb63f5ccf4acacf7fb6e5..4ccff1f5f32f8b0b46e68348c70f9dff27cca358 100644
--- a/src/array.js
+++ b/src/array.js
@@ -1492,14 +1492,21 @@
}
-function InnerArrayReduce(callback, current, array, length, argumentsLength) {
+function ArrayReduce(callback, current) {
+ CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduce");
+
+ // Pull out the length so that modifications to the length in the
+ // loop will not affect the looping and side effects are visible.
+ var array = $toObject(this);
+ var length = $toUint32(array.length);
+
if (!IS_SPEC_FUNCTION(callback)) {
throw MakeTypeError(kCalledNonCallable, callback);
}
var is_array = IS_ARRAY(array);
var i = 0;
- find_initial: if (argumentsLength < 2) {
+ find_initial: if (%_ArgumentsLength() < 2) {
for (; i < length; i++) {
if (HAS_INDEX(array, i, is_array)) {
current = array[i++];
@@ -1522,27 +1529,21 @@
}
-function ArrayReduce(callback, current) {
- CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduce");
-
- // Pull out the length so that modifications to the length in the
- // loop will not affect the looping and side effects are visible.
+function ArrayReduceRight(callback, current) {
+ CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight");
+
+ // Pull out the length so that side effects are visible before the
+ // callback function is checked.
var array = $toObject(this);
var length = $toUint32(array.length);
- return InnerArrayReduce(callback, current, array, length,
- %_ArgumentsLength());
-}
-
-
-function InnerArrayReduceRight(callback, current, array, length,
- argumentsLength) {
+
if (!IS_SPEC_FUNCTION(callback)) {
throw MakeTypeError(kCalledNonCallable, callback);
}
var is_array = IS_ARRAY(array);
var i = length - 1;
- find_initial: if (argumentsLength < 2) {
+ find_initial: if (%_ArgumentsLength() < 2) {
for (; i >= 0; i--) {
if (HAS_INDEX(array, i, is_array)) {
current = array[i--];
@@ -1562,18 +1563,6 @@
}
}
return current;
-}
-
-
-function ArrayReduceRight(callback, current) {
- CHECK_OBJECT_COERCIBLE(this, "Array.prototype.reduceRight");
-
- // Pull out the length so that side effects are visible before the
- // callback function is checked.
- var array = $toObject(this);
- var length = $toUint32(array.length);
- return InnerArrayReduceRight(callback, current, array, length,
- %_ArgumentsLength());
}
// ES5, 15.4.3.2
@@ -1684,8 +1673,6 @@
to.InnerArrayJoin = InnerArrayJoin;
to.InnerArrayLastIndexOf = InnerArrayLastIndexOf;
to.InnerArrayMap = InnerArrayMap;
- to.InnerArrayReduce = InnerArrayReduce;
- to.InnerArrayReduceRight = InnerArrayReduceRight;
to.InnerArrayReverse = InnerArrayReverse;
to.InnerArraySome = InnerArraySome;
to.InnerArraySort = InnerArraySort;
« no previous file with comments | « no previous file | src/harmony-typedarray.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698