Reviewers: kasperl, Description: Implemented fast case for NumberToString where the result is a single character string.
Please review this at http://codereview.chromium.org/126189 SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/ Affected files: M src/runtime.cc 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. + 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"; + return Heap::LookupSingleCharacterStringFromCode(chars[value]); + } + } + + // Slow case. CONVERT_DOUBLE_CHECKED(value, args[0]); if (isnan(value)) { return Heap::AllocateStringFromAscii(CStrVector("NaN")); --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
