| 1 | /* |
| 2 | * Copyright (C) 2009 Apple Inc. All Rights Reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #ifndef NumericStrings_h |
| 27 | #define NumericStrings_hcxx . . $ `src/3rdparty/javascriptcore/JavaScriptCore/runtime/NumericStrings.h:27:9`! |
| 28 | |
| 29 | #include "UString.h"cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/runtime/UString.h`/ |
| 30 | #include <wtf/HashFunctions.h>cxx . . $ `<file>/src/3rdparty/javascriptcore/JavaScriptCore/wtf/HashFunctions.h`/ |
| 31 | |
| 32 | namespace JSCcxx . . $ QTJSC/ { |
| 33 | |
| 34 | class NumericStringscxx . . $ QTJSC/NumericStrings# { |
| 35 | public: |
| 36 | UStringcxx . . $ QTJSC/UString# addcxx . . $ QTJSC/NumericStrings#add(f1fb2f715195f7ba).(double d) |
| 37 | { |
| 38 | CacheEntrycxx . . $ QTJSC/NumericStrings#CacheEntry#<double>& entry = lookupcxx . . $ QTJSC/NumericStrings#lookup(83ae6ef2cc3c8567).(d); |
| 39 | if (d ==cxx . . $ QTJSC/`operator==`(8208a731c2dadbc2). entry.key && !entry.value.isNull()) |
| 40 | return entry.value; |
| 41 | entry.key = d; |
| 42 | entry.value = UStringcxx . . $ QTJSC/UString#::fromcxx . . $ QTJSC/UString#from(f1fb2f715195f7ba).(d); |
| 43 | return entry.value; |
| 44 | } |
| 45 | |
| 46 | UStringcxx . . $ QTJSC/UString# addcxx . . $ QTJSC/NumericStrings#add(1ed97944dfe079ad).(int i) |
| 47 | { |
| 48 | CacheEntrycxx . . $ QTJSC/NumericStrings#CacheEntry#<int>& entry = lookupcxx . . $ QTJSC/NumericStrings#lookup(26439a71e23d423f).(i); |
| 49 | if (i ==cxx . . $ QTJSC/`operator==`(2a94f8346549a239). entry.key && !entry.value.isNull()) |
| 50 | return entry.value; |
| 51 | entry.key = i; |
| 52 | entry.value = UStringcxx . . $ QTJSC/UString#::fromcxx . . $ QTJSC/UString#from(1ed97944dfe079ad).(i); |
| 53 | return entry.value; |
| 54 | } |
| 55 | |
| 56 | private: |
| 57 | static const size_t cacheSizecxx . . $ QTJSC/NumericStrings#cacheSize. = 64; |
| 58 | |
| 59 | template<typename T> |
| 60 | struct CacheEntrycxx . . $ QTJSC/NumericStrings#CacheEntry# { |
| 61 | T keycxx . . $ QTJSC/NumericStrings#CacheEntry#key.; |
| 62 | UStringcxx . . $ QTJSC/UString# valuecxx . . $ QTJSC/NumericStrings#CacheEntry#value.; |
| 63 | }; |
| 64 | |
| 65 | CacheEntrycxx . . $ QTJSC/NumericStrings#CacheEntry#<double>& lookupcxx . . $ QTJSC/NumericStrings#lookup(83ae6ef2cc3c8567).(double d) { return doubleCache[WTFcxx . . $ `<built-in>:467:9`!::FloatHash<double>::hash(d) & (cacheSize - 1)]; } |
| 66 | CacheEntrycxx . . $ QTJSC/NumericStrings#CacheEntry#<int>& lookupcxx . . $ QTJSC/NumericStrings#lookup(26439a71e23d423f).(int i) { return intCache[WTFcxx . . $ `<built-in>:467:9`!::IntHash<int>::hash(i) & (cacheSize - 1)]; } |
| 67 | |
| 68 | CacheEntrycxx . . $ QTJSC/NumericStrings#CacheEntry#<double> doubleCachecxx . . $ QTJSC/NumericStrings#doubleCache.[cacheSizecxx . . $ QTJSC/NumericStrings#cacheSize.]; |
| 69 | CacheEntrycxx . . $ QTJSC/NumericStrings#CacheEntry#<int> intCachecxx . . $ QTJSC/NumericStrings#intCache.[cacheSizecxx . . $ QTJSC/NumericStrings#cacheSize.]; |
| 70 | }; |
| 71 | |
| 72 | } // namespace JSC |
| 73 | |
| 74 | #endif // NumericStrings_h |