Ignore:
Timestamp:
Aug 20, 2009, 10:41:54 PM (16 years ago)
Author:
[email protected]
Message:

Added a number => string cache.

Patch by Geoffrey Garen <[email protected]> on 2009-08-20
Reviewed by Maciej Stachowiak.

1.07x faster on v8 (1.7x faster on v8-splay).
1.004x faster on SunSpider.

  • runtime/JSCell.h: Moved JSValue::toString to JSString.h.
  • runtime/JSGlobalData.h: Holds the cache.
  • runtime/JSNumberCell.cpp:

(JSC::JSNumberCell::toString):
(JSC::JSNumberCell::toThisString): Removed -0 special case.
UString handles this now, since too many clients were
special-casing it.

  • runtime/JSString.h:

(JSC::JSValue::toString): Use the cache when converting
an int or double to string.

  • runtime/Operations.h:

(JSC::concatenateStrings): Call toString to take advantage
of the cache.

  • runtime/SmallStrings.h:

(JSC::NumericStrings::add):
(JSC::NumericStrings::lookup): The cache.

  • runtime/UString.cpp:

(JSC::UString::from): Added -0 special case mentioned above.
Removed appendNumeric because it's mutually exclusive with the
cache.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/UString.cpp

    r47102 r47622  
    10281028    if (isnan(d))
    10291029        return "NaN";
     1030    if (!d)
     1031        return "0"; // -0 -> "0"
    10301032
    10311033    char buf[80];
     
    12101212}
    12111213
    1212 UString& UString::appendNumeric(int i)
    1213 {
    1214     m_rep = concatenate(rep(), i);
    1215     return *this;
    1216 }
    1217 
    1218 UString& UString::appendNumeric(double d)
    1219 {
    1220     m_rep = concatenate(rep(), d);
    1221     return *this;
    1222 }
    1223 
    12241214UString& UString::append(const char* t)
    12251215{
Note: See TracChangeset for help on using the changeset viewer.