Commit bd0f2e39 authored by paroga@webkit.org's avatar paroga@webkit.org

2010-12-31 Patrick Gansterer <paroga@webkit.org>

        Reviewed by Darin Adler.

        Add a fast case for ASCII strings in HashAndUTF8CharactersTranslator::equal
        https://bugs.webkit.org/show_bug.cgi?id=50517

        This change shows about 2% performance win on the xml-parser benchmark.

        * wtf/text/AtomicString.cpp:
        (WTF::HashAndUTF8CharactersTranslator::equal):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74829 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 06afa2d8
2010-12-31 Patrick Gansterer <paroga@webkit.org>
Reviewed by Darin Adler.
Add a fast case for ASCII strings in HashAndUTF8CharactersTranslator::equal
https://bugs.webkit.org/show_bug.cgi?id=50517
This change shows about 2% performance win on the xml-parser benchmark.
* wtf/text/AtomicString.cpp:
(WTF::HashAndUTF8CharactersTranslator::equal):
2010-12-30 Patrick Gansterer <paroga@webkit.org>
Reviewed by Ariya Hidayat.
......
......@@ -225,7 +225,22 @@ struct HashAndUTF8CharactersTranslator {
static bool equal(StringImpl* const& string, const HashAndUTF8Characters& buffer)
{
return equalUTF16WithUTF8(string->characters(), string->characters() + string->length(), buffer.characters, buffer.characters + buffer.length);
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)
return equalUTF16WithUTF8(stringCharacters, stringCharacters + string->length(), buffer.characters, buffer.characters + buffer.length);
for (unsigned i = 0; i < buffer.length; ++i) {
ASSERT(isASCII(buffer.characters[i]));
if (stringCharacters[i] != buffer.characters[i])
return false;
}
return true;
}
static void translate(StringImpl*& location, const HashAndUTF8Characters& buffer, unsigned hash)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment