From 6882a04fb36642862b11efe514251d32070c3d65 Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Thu, 25 Aug 2016 19:20:41 +0300 Subject: Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443) Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev --- Source/JavaScriptCore/runtime/NumericStrings.h | 106 ++++++++++++------------- 1 file changed, 53 insertions(+), 53 deletions(-) (limited to 'Source/JavaScriptCore/runtime/NumericStrings.h') diff --git a/Source/JavaScriptCore/runtime/NumericStrings.h b/Source/JavaScriptCore/runtime/NumericStrings.h index 68bfbd06a..ac8d41603 100644 --- a/Source/JavaScriptCore/runtime/NumericStrings.h +++ b/Source/JavaScriptCore/runtime/NumericStrings.h @@ -26,72 +26,72 @@ #ifndef NumericStrings_h #define NumericStrings_h -#include +#include #include #include namespace JSC { - class NumericStrings { - public: - ALWAYS_INLINE String add(double d) - { - CacheEntry& entry = lookup(d); - if (!entry.value.isNull() && d == entry.key) - return entry.value; - entry.key = d; - entry.value = String::numberToStringECMAScript(d); +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; + } - ALWAYS_INLINE String add(int i) - { - if (static_cast(i) < cacheSize) - return lookupSmallString(static_cast(i)); - CacheEntry& entry = lookup(i); - if (!entry.value.isNull() && i == entry.key) - return entry.value; - entry.key = i; - entry.value = String::number(i); + 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; + } - ALWAYS_INLINE String add(unsigned i) - { - if (i < cacheSize) - return lookupSmallString(static_cast(i)); - CacheEntry& entry = lookup(i); - if (!entry.value.isNull() && i == entry.key) - return entry.value; - entry.key = i; - entry.value = String::number(i); + 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; - } - private: - static const size_t cacheSize = 64; + entry.key = i; + entry.value = String::number(i); + return entry.value; + } +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]; + } - FixedArray, cacheSize> doubleCache; - FixedArray, cacheSize> intCache; - FixedArray, cacheSize> unsignedCache; - FixedArray smallIntCache; - }; + std::array, cacheSize> doubleCache; + std::array, cacheSize> intCache; + std::array, cacheSize> unsignedCache; + std::array smallIntCache; +}; } // namespace JSC -- cgit v1.2.1