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

Unified Diff: src/js/array.js

Issue 1408213004: Refactor array construction for map, filter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Test improvement Created 5 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/regress/regress-544991.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/array.js
diff --git a/src/js/array.js b/src/js/array.js
index be36145feb5ad7e95043836bc057f1ed384941a4..4146600ed030e97de606e0a7ea29bbf2a3374192 100644
--- a/src/js/array.js
+++ b/src/js/array.js
@@ -1196,7 +1196,9 @@ function InnerArrayFilter(f, receiver, array, length) {
}
}
}
- return accumulator;
+ var result = new GlobalArray();
+ %MoveArrayContents(accumulator, result);
+ return result;
}
function ArrayFilter(f, receiver) {
@@ -1206,10 +1208,7 @@ function ArrayFilter(f, receiver) {
// loop will not affect the looping and side effects are visible.
var array = TO_OBJECT(this);
var length = TO_LENGTH_OR_UINT32(array.length);
- var accumulator = InnerArrayFilter(f, receiver, array, length);
- var result = new GlobalArray();
- %MoveArrayContents(accumulator, result);
- return result;
+ return InnerArrayFilter(f, receiver, array, length);
}
function InnerArrayForEach(f, receiver, array, length) {
@@ -1309,7 +1308,9 @@ function InnerArrayMap(f, receiver, array, length) {
accumulator[i] = %_Call(f, receiver, element, i, array);
}
}
- return accumulator;
+ var result = new GlobalArray();
+ %MoveArrayContents(accumulator, result);
+ return result;
}
@@ -1320,10 +1321,7 @@ function ArrayMap(f, receiver) {
// loop will not affect the looping and side effects are visible.
var array = TO_OBJECT(this);
var length = TO_LENGTH_OR_UINT32(array.length);
- var accumulator = InnerArrayMap(f, receiver, array, length);
- var result = new GlobalArray();
- %MoveArrayContents(accumulator, result);
- return result;
+ return InnerArrayMap(f, receiver, array, length);
}
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-544991.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698