diff options
Diffstat (limited to 'Source/JavaScriptCore/runtime/Identifier.cpp')
-rw-r--r-- | Source/JavaScriptCore/runtime/Identifier.cpp | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/Source/JavaScriptCore/runtime/Identifier.cpp b/Source/JavaScriptCore/runtime/Identifier.cpp index 182bcc462..20770928c 100644 --- a/Source/JavaScriptCore/runtime/Identifier.cpp +++ b/Source/JavaScriptCore/runtime/Identifier.cpp @@ -145,56 +145,6 @@ PassRefPtr<StringImpl> Identifier::add8(JSGlobalData* globalData, const UChar* s return addResult.isNewEntry ? adoptRef(*addResult.iterator) : *addResult.iterator; } -template <typename CharType> -ALWAYS_INLINE uint32_t Identifier::toUInt32FromCharacters(const CharType* characters, unsigned length, bool& ok) -{ - // Get the first character, turning it into a digit. - uint32_t value = characters[0] - '0'; - if (value > 9) - return 0; - - // Check for leading zeros. If the first characher is 0, then the - // length of the string must be one - e.g. "042" is not equal to "42". - if (!value && length > 1) - return 0; - - while (--length) { - // Multiply value by 10, checking for overflow out of 32 bits. - if (value > 0xFFFFFFFFU / 10) - return 0; - value *= 10; - - // Get the next character, turning it into a digit. - uint32_t newValue = *(++characters) - '0'; - if (newValue > 9) - return 0; - - // Add in the old value, checking for overflow out of 32 bits. - newValue += value; - if (newValue < value) - return 0; - value = newValue; - } - - ok = true; - return value; -} - -uint32_t Identifier::toUInt32(const UString& string, bool& ok) -{ - ok = false; - - unsigned length = string.length(); - - // An empty string is not a number. - if (!length) - return 0; - - if (string.is8Bit()) - return toUInt32FromCharacters(string.characters8(), length, ok); - return toUInt32FromCharacters(string.characters16(), length, ok); -} - PassRefPtr<StringImpl> Identifier::addSlowCase(JSGlobalData* globalData, StringImpl* r) { ASSERT(!r->isIdentifier()); |