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

Unified Diff: src/runtime.js

Issue 1348943002: Slightly optimize performance of ToLength() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/macros.py ('k') | src/v8natives.js » ('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 39939b16027f9447967becf4e3b374aafdb8fd21..c41c4d91ddeb85e5cf7eec5aa83a4b55a380a246 100644
--- a/src/runtime.js
+++ b/src/runtime.js
@@ -300,10 +300,11 @@ function ToInteger(x) {
// ES6, draft 08-24-14, section 7.1.15
function ToLength(arg) {
- arg = ToInteger(arg);
+ if (!%_IsSmi(arg)) {
+ arg = %NumberToInteger(ToNumber(arg));
+ }
if (arg < 0) return 0;
- return arg < GlobalNumber.MAX_SAFE_INTEGER ? arg
- : GlobalNumber.MAX_SAFE_INTEGER;
+ return arg < kMaxSafeInteger ? arg : kMaxSafeInteger;
}
« no previous file with comments | « src/macros.py ('k') | src/v8natives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698