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

Unified Diff: src/js/array.js

Issue 1706213002: Tune Array.forEach, fix Array functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: correctify inherited elements Created 4 years, 10 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/js/macros.py » ('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 a42aad590cd8a1905a29a16148544093a2e6d6ea..58e7f59e79811ef5929ec238a26d93255577c024 100644
--- a/src/js/array.js
+++ b/src/js/array.js
@@ -1257,10 +1257,19 @@ function InnerArrayForEach(f, receiver, array, length) {
if (!IS_CALLABLE(f)) throw MakeTypeError(kCalledNonCallable, f);
var is_array = IS_ARRAY(array);
- for (var i = 0; i < length; i++) {
- if (HAS_INDEX(array, i, is_array)) {
- var element = array[i];
- %_Call(f, receiver, element, i, array);
+ if (IS_UNDEFINED(receiver)) {
adamk 2016/02/18 17:43:32 FWIW we used to do something even fancier, but bme
Toon Verwaest 2016/02/24 09:09:03 That code was quite different. The bug there iirc
+ for (var i = 0; i < length; i++) {
+ if (HAS_INDEX(array, i, is_array)) {
+ var element = array[i];
+ f(element, i, array);
+ }
+ }
+ } else {
+ for (var i = 0; i < length; i++) {
+ if (HAS_INDEX(array, i, is_array)) {
+ var element = array[i];
+ %_Call(f, receiver, element, i, array);
+ }
}
}
}
« no previous file with comments | « no previous file | src/js/macros.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698