Commit 03356a0e authored by bak@chromium.org's avatar bak@chromium.org

Implemented fast case for NumberToString where the result is a single character string.

Review URL: http://codereview.chromium.org/126189

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@2175 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 97482a43
......@@ -2416,6 +2416,19 @@ static Object* Runtime_NumberToRadixString(Arguments args) {
NoHandleAllocation ha;
ASSERT(args.length() == 2);
// Fast case where the result is a one character string.
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 kCharTable[] = "0123456789abcdefghijklmnopqrstuvwxyz";
return Heap::LookupSingleCharacterStringFromCode(kCharTable[value]);
}
}
// Slow case.
CONVERT_DOUBLE_CHECKED(value, args[0]);
if (isnan(value)) {
return Heap::AllocateStringFromAscii(CStrVector("NaN"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment