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

Unified Diff: src/runtime.cc

Issue 126189: Implemented fast case for NumberToString where the result is a single charact... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 2174)
+++ src/runtime.cc (working copy)
@@ -2416,6 +2416,19 @@
NoHandleAllocation ha;
ASSERT(args.length() == 2);
+ // Fast case where the result is a one char string.
Kasper Lund 2009/06/16 06:41:18 char -> character
+ if (args[0]->IsSmi() && args[1]->IsSmi()) {
+ int value = Smi::cast(args[0])->value();
+ int radix = Smi::cast(args[1])->value();
+ if (value >= 0 && value < radix) {
+ RUNTIME_ASSERT(radix <= 36);
+ // Character array used for conversion.
+ static const char chars[] = "0123456789abcdefghijklmnopqrstuvwxyz";
Kasper Lund 2009/06/16 06:41:18 Should be something like kChars or kCharsMap, righ
+ return Heap::LookupSingleCharacterStringFromCode(chars[value]);
+ }
+ }
+
+ // Slow case.
CONVERT_DOUBLE_CHECKED(value, args[0]);
if (isnan(value)) {
return Heap::AllocateStringFromAscii(CStrVector("NaN"));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698