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

Unified Diff: src/harmony-array.js

Issue 553413002: Array.prototype.{every, filter, find, findIndex, forEach, map, some}: Use fresh primitive wrapper f… (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix last issues. Created 6 years, 3 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
Index: src/harmony-array.js
diff --git a/src/harmony-array.js b/src/harmony-array.js
index 88b878f0a76ef594f64f7905d61459c05749724b..c4b69c75817710b1884d88be6deab1bc44606cc5 100644
--- a/src/harmony-array.js
+++ b/src/harmony-array.js
@@ -27,15 +27,15 @@ function ArrayFind(predicate /* thisArg */) { // length == 1
}
if (IS_NULL_OR_UNDEFINED(thisArg)) {
- thisArg = %GetDefaultReceiver(predicate) || thisArg;
- } else if (!IS_SPEC_OBJECT(thisArg) && %IsSloppyModeFunction(predicate)) {
- thisArg = ToObject(thisArg);
+ thisArg = %GetDefaultthisArg(predicate) || thisArg;
wingo 2014/09/30 16:01:36 Typo. Did these tests pass for you? :)
}
+ var needs_wrapper = SHOULD_CREATE_WRAPPER(predicate, thisArg);
wingo 2014/09/30 16:01:36 Here we are adding a test; SHOULD_CREATE_WRAPPER l
for (var i = 0; i < length; i++) {
if (i in array) {
var element = array[i];
- if (%_CallFunction(thisArg, element, i, array, predicate)) {
+ var newThisArg = needs_wrapper ? ToObject(thisArg) : thisArg;
+ if (%_CallFunction(newThisArg, element, i, array, predicate)) {
return element;
}
}
@@ -62,15 +62,15 @@ function ArrayFindIndex(predicate /* thisArg */) { // length == 1
}
if (IS_NULL_OR_UNDEFINED(thisArg)) {
- thisArg = %GetDefaultReceiver(predicate) || thisArg;
- } else if (!IS_SPEC_OBJECT(thisArg) && %IsSloppyModeFunction(predicate)) {
- thisArg = ToObject(thisArg);
+ thisArg = %GetDefaultthisArg(predicate) || thisArg;
}
+ var needs_wrapper = SHOULD_CREATE_WRAPPER(predicate, thisArg);
wingo 2014/09/30 16:01:36 same here and in similar places in the patch
for (var i = 0; i < length; i++) {
if (i in array) {
var element = array[i];
- if (%_CallFunction(thisArg, element, i, array, predicate)) {
+ var newThisArg = needs_wrapper ? ToObject(thisArg) : thisArg;
+ if (%_CallFunction(newThisArg, element, i, array, predicate)) {
return i;
}
}
« no previous file with comments | « src/collection.js ('k') | src/macros.py » ('j') | test/mjsunit/es6/collections.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698