Reviewers: Mads Ager,

Description:
Improve parseInt.

Please review this at http://codereview.chromium.org/6546055/

SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/

Affected files:
  M     src/v8natives.js


Index: src/v8natives.js
===================================================================
--- src/v8natives.js    (revision 6886)
+++ src/v8natives.js    (working copy)
@@ -92,7 +92,7 @@

 // ECMA-262 - 15.1.2.2
 function GlobalParseInt(string, radix) {
-  if (IS_UNDEFINED(radix)) {
+  if (IS_UNDEFINED(radix) || radix === 10 || radix === 0) {
     // Some people use parseInt instead of Math.floor.  This
     // optimization makes parseInt on a Smi 12 times faster (60ns
     // vs 800ns).  The following optimization makes parseInt on a
@@ -105,7 +105,7 @@
       // Truncate number.
       return string | 0;
     }
-    radix = 0;
+    if (IS_UNDEFINED(radix)) radix = 0;
   } else {
     radix = TO_INT32(radix);
     if (!(radix == 0 || (2 <= radix && radix <= 36)))


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to