From: bak@chromium.org Date: Tue, 16 Jun 2009 06:44:09 +0000 (+0000) Subject: Implemented fast case for NumberToString where the result is a single character string. X-Git-Tag: upstream/4.7.83~23902 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=03356a0e60aea91772dff52702790349786d2b9f;p=platform%2Fupstream%2Fv8.git 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 --- diff --git a/src/runtime.cc b/src/runtime.cc index 316f8c429..d1c9162d1 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -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"));