From: sandholm@chromium.org Date: Tue, 22 Feb 2011 11:21:15 +0000 (+0000) Subject: Improve parseInt. X-Git-Tag: upstream/4.7.83~20129 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9d4b0fa93297e0fe57ade36cf13f2c8f45913aeb;p=platform%2Fupstream%2Fv8.git Improve parseInt. Review URL: http://codereview.chromium.org/6546055 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6888 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/v8natives.js b/src/v8natives.js index 884b6f4..91e19c1 100644 --- a/src/v8natives.js +++ b/src/v8natives.js @@ -92,7 +92,7 @@ function GlobalIsFinite(number) { // 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 @@ function GlobalParseInt(string, radix) { // 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)))