Changeset 55599 in webkit for trunk/JavaScriptCore/runtime/NumericStrings.h
- Timestamp:
- Mar 5, 2010, 3:29:13 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/NumericStrings.h
r47622 r55599 46 46 UString add(int i) 47 47 { 48 if (static_cast<unsigned>(i) < cacheSize) 49 return lookupSmallString(static_cast<unsigned>(i)); 48 50 CacheEntry<int>& entry = lookup(i); 49 51 if (i == entry.key && !entry.value.isNull()) … … 54 56 } 55 57 58 UString add(unsigned i) 59 { 60 if (i < cacheSize) 61 return lookupSmallString(static_cast<unsigned>(i)); 62 CacheEntry<unsigned>& entry = lookup(i); 63 if (i == entry.key && !entry.value.isNull()) 64 return entry.value; 65 entry.key = i; 66 entry.value = UString::from(i); 67 return entry.value; 68 } 56 69 private: 57 70 static const size_t cacheSize = 64; … … 65 78 CacheEntry<double>& lookup(double d) { return doubleCache[WTF::FloatHash<double>::hash(d) & (cacheSize - 1)]; } 66 79 CacheEntry<int>& lookup(int i) { return intCache[WTF::IntHash<int>::hash(i) & (cacheSize - 1)]; } 80 CacheEntry<unsigned>& lookup(unsigned i) { return unsignedCache[WTF::IntHash<unsigned>::hash(i) & (cacheSize - 1)]; } 81 const UString& lookupSmallString(unsigned i) 82 { 83 ASSERT(i < cacheSize); 84 if (smallIntCache[i].isNull()) 85 smallIntCache[i] = UString::from(i); 86 return smallIntCache[i]; 87 } 67 88 68 89 CacheEntry<double> doubleCache[cacheSize]; 69 90 CacheEntry<int> intCache[cacheSize]; 91 CacheEntry<unsigned> unsignedCache[cacheSize]; 92 UString smallIntCache[cacheSize]; 70 93 }; 71 94
Note:
See TracChangeset
for help on using the changeset viewer.