From 41386e9cb918eed93b3f13648cbef387e371e451 Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Wed, 20 May 2015 09:56:07 +0000 Subject: webkitgtk-2.4.9 --- Source/JavaScriptCore/runtime/NumericStrings.h | 104 ++++++++++++------------- 1 file changed, 52 insertions(+), 52 deletions(-) (limited to 'Source/JavaScriptCore/runtime/NumericStrings.h') diff --git a/Source/JavaScriptCore/runtime/NumericStrings.h b/Source/JavaScriptCore/runtime/NumericStrings.h index ac8d41603..3bb5b91c8 100644 --- a/Source/JavaScriptCore/runtime/NumericStrings.h +++ b/Source/JavaScriptCore/runtime/NumericStrings.h @@ -32,66 +32,66 @@ namespace JSC { -class NumericStrings { -public: - ALWAYS_INLINE String add(double d) - { - CacheEntry& entry = lookup(d); - if (d == entry.key && !entry.value.isNull()) + class NumericStrings { + public: + ALWAYS_INLINE String add(double d) + { + CacheEntry& entry = lookup(d); + if (d == entry.key && !entry.value.isNull()) + return entry.value; + entry.key = d; + entry.value = String::numberToStringECMAScript(d); return entry.value; - entry.key = d; - entry.value = String::numberToStringECMAScript(d); - return entry.value; - } + } - ALWAYS_INLINE String add(int i) - { - if (static_cast(i) < cacheSize) - return lookupSmallString(static_cast(i)); - CacheEntry& entry = lookup(i); - if (i == entry.key && !entry.value.isNull()) + ALWAYS_INLINE String add(int i) + { + if (static_cast(i) < cacheSize) + return lookupSmallString(static_cast(i)); + CacheEntry& entry = lookup(i); + if (i == entry.key && !entry.value.isNull()) + return entry.value; + entry.key = i; + entry.value = String::number(i); return entry.value; - entry.key = i; - entry.value = String::number(i); - return entry.value; - } + } - ALWAYS_INLINE String add(unsigned i) - { - if (i < cacheSize) - return lookupSmallString(static_cast(i)); - CacheEntry& entry = lookup(i); - if (i == entry.key && !entry.value.isNull()) + ALWAYS_INLINE String add(unsigned i) + { + if (i < cacheSize) + return lookupSmallString(static_cast(i)); + CacheEntry& entry = lookup(i); + if (i == entry.key && !entry.value.isNull()) + return entry.value; + entry.key = i; + entry.value = String::number(i); return entry.value; - entry.key = i; - entry.value = String::number(i); - return entry.value; - } -private: - static const size_t cacheSize = 64; + } + private: + static const size_t cacheSize = 64; - template - struct CacheEntry { - T key; - String value; - }; + template + struct CacheEntry { + T key; + String value; + }; - CacheEntry& lookup(double d) { return doubleCache[WTF::FloatHash::hash(d) & (cacheSize - 1)]; } - CacheEntry& lookup(int i) { return intCache[WTF::IntHash::hash(i) & (cacheSize - 1)]; } - CacheEntry& lookup(unsigned i) { return unsignedCache[WTF::IntHash::hash(i) & (cacheSize - 1)]; } - ALWAYS_INLINE const String& lookupSmallString(unsigned i) - { - ASSERT(i < cacheSize); - if (smallIntCache[i].isNull()) - smallIntCache[i] = String::number(i); - return smallIntCache[i]; - } + CacheEntry& lookup(double d) { return doubleCache[WTF::FloatHash::hash(d) & (cacheSize - 1)]; } + CacheEntry& lookup(int i) { return intCache[WTF::IntHash::hash(i) & (cacheSize - 1)]; } + CacheEntry& lookup(unsigned i) { return unsignedCache[WTF::IntHash::hash(i) & (cacheSize - 1)]; } + ALWAYS_INLINE const String& lookupSmallString(unsigned i) + { + ASSERT(i < cacheSize); + if (smallIntCache[i].isNull()) + smallIntCache[i] = String::number(i); + return smallIntCache[i]; + } - std::array, cacheSize> doubleCache; - std::array, cacheSize> intCache; - std::array, cacheSize> unsignedCache; - std::array smallIntCache; -}; + std::array, cacheSize> doubleCache; + std::array, cacheSize> intCache; + std::array, cacheSize> unsignedCache; + std::array smallIntCache; + }; } // namespace JSC -- cgit v1.2.1