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

Unified Diff: src/runtime.js

Issue 754863002: Optimize testing for an index's existence in packed Arrays (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased for landing Created 6 years 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 | « src/macros.py ('k') | src/runtime/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.js
diff --git a/src/runtime.js b/src/runtime.js
index 4d15d205a495b6623cf399ccd0dd36973cac22c4..dbb8e45b343370585f836aa1dd70301289575b3c 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -324,8 +324,13 @@ function IN(x) {
if (!IS_SPEC_OBJECT(x)) {
throw %MakeTypeError('invalid_in_operator_use', [this, x]);
}
- return %_IsNonNegativeSmi(this) ?
- %HasElement(x, this) : %HasProperty(x, %ToName(this));
+ if (%_IsNonNegativeSmi(this)) {
+ if (IS_ARRAY(x) && %_HasFastPackedElements(x)) {
+ return this < x.length;
+ }
+ return %HasElement(x, this);
+ }
+ return %HasProperty(x, %ToName(this));
}
« no previous file with comments | « src/macros.py ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698