diff options
Diffstat (limited to 'Source/WTF/wtf/text/AtomicString.cpp')
| -rw-r--r-- | Source/WTF/wtf/text/AtomicString.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Source/WTF/wtf/text/AtomicString.cpp b/Source/WTF/wtf/text/AtomicString.cpp index cbb5a20ee..a37c50e6f 100644 --- a/Source/WTF/wtf/text/AtomicString.cpp +++ b/Source/WTF/wtf/text/AtomicString.cpp @@ -187,11 +187,26 @@ struct HashAndUTF8CharactersTranslator { if (buffer.utf16Length != string->length()) return false; - const UChar* stringCharacters = string->characters(); - // If buffer contains only ASCII characters UTF-8 and UTF16 length are the same. - if (buffer.utf16Length != buffer.length) + if (buffer.utf16Length != buffer.length) { + const UChar* stringCharacters = string->characters(); + return equalUTF16WithUTF8(stringCharacters, stringCharacters + string->length(), buffer.characters, buffer.characters + buffer.length); + } + + if (string->is8Bit()) { + const LChar* stringCharacters = string->characters8(); + + for (unsigned i = 0; i < buffer.length; ++i) { + ASSERT(isASCII(buffer.characters[i])); + if (stringCharacters[i] != buffer.characters[i]) + return false; + } + + return true; + } + + const UChar* stringCharacters = string->characters16(); for (unsigned i = 0; i < buffer.length; ++i) { ASSERT(isASCII(buffer.characters[i])); |
