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

Issue 391014: Small optimizations to parseInt (Closed)

Created:
11 years, 1 month ago by Jan de Mooij
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Small optimizations to parseInt: - Second argument to Runtime_StringParseInt is always a smi, avoid converting to double and back to int - parseInt(positive float) is more common than parseInt(negative float), so check for positive numbers first.

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+3 lines, -4 lines) Patch
M src/runtime.cc View 1 chunk +1 line, -2 lines 3 comments Download
M src/v8natives.js View 1 chunk +2 lines, -2 lines 1 comment Download

Messages

Total messages: 4 (0 generated)
Jan de Mooij
11 years, 1 month ago (2009-11-11 10:51:00 UTC) #1
Erik Corry
http://codereview.chromium.org/391014/diff/1/3 File src/runtime.cc (right): http://codereview.chromium.org/391014/diff/1/3#newcode3390 Line 3390: CONVERT_SMI_CHECKED(radix, args[1]); This version doesn't work if the ...
11 years, 1 month ago (2009-11-11 11:16:49 UTC) #2
Lasse Reichstein
Add some tests for fractional bases in parse-int-float.js, and it'll LGTM. http://codereview.chromium.org/391014/diff/1/3 File src/runtime.cc (right): ...
11 years, 1 month ago (2009-11-11 11:43:34 UTC) #3
Erik Corry
11 years, 1 month ago (2009-11-13 12:24:22 UTC) #4
http://codereview.chromium.org/391014/diff/1/3
File src/runtime.cc (right):

http://codereview.chromium.org/391014/diff/1/3#newcode3390
Line 3390: CONVERT_SMI_CHECKED(radix, args[1]);
On 2009/11/11 11:16:49, Erik Corry wrote:
> This version doesn't work if the argument is not a Smi.  It throws an
exception
> instead of just working.  We should have a test that parseInt("100", 16.1) ==
> 256.

My apologies, I was too fast with this comment.  The 16.1 case is caught in the
js code, so the patch LGTM.

Powered by Google App Engine
This is Rietveld 408576698