| Index: Source/core/html/parser/HTMLParserIdioms.cpp
|
| diff --git a/Source/core/html/parser/HTMLParserIdioms.cpp b/Source/core/html/parser/HTMLParserIdioms.cpp
|
| index 2173ef531261f3be7ebcc273d7cee35f4005d787..f538c54cc5bfc600db038025427f6b21559c110a 100644
|
| --- a/Source/core/html/parser/HTMLParserIdioms.cpp
|
| +++ b/Source/core/html/parser/HTMLParserIdioms.cpp
|
| @@ -29,6 +29,7 @@
|
| #include "wtf/MathExtras.h"
|
| #include "wtf/text/AtomicString.h"
|
| #include "wtf/text/StringBuilder.h"
|
| +#include "wtf/text/StringHash.h"
|
|
|
| namespace WebCore {
|
|
|
| @@ -278,9 +279,31 @@ bool threadSafeMatch(const QualifiedName& a, const QualifiedName& b)
|
| return threadSafeEqual(a.localName().impl(), b.localName().impl());
|
| }
|
|
|
| -bool threadSafeMatch(const HTMLIdentifier& localName, const QualifiedName& qName)
|
| +bool threadSafeMatch(const String& localName, const QualifiedName& qName)
|
| {
|
| - return threadSafeEqual(localName.asStringImpl(), qName.localName().impl());
|
| + return threadSafeEqual(localName.impl(), qName.localName().impl());
|
| +}
|
| +
|
| +StringImpl* findStringIfStatic(const UChar* characters, unsigned length)
|
| +{
|
| + // We don't need to try hashing if we know the string is too long.
|
| + if (length > StringImpl::highestStaticStringLength())
|
| + return 0;
|
| + // computeHashAndMaskTop8Bits is the function StringImpl::hash() uses.
|
| + unsigned hash = StringHasher::computeHashAndMaskTop8Bits(characters, length);
|
| + const WTF::StaticStringsTable& table = StringImpl::allStaticStrings();
|
| + ASSERT(!table.isEmpty());
|
| +
|
| + WTF::StaticStringsTable::const_iterator it = table.find(hash);
|
| + if (it == table.end())
|
| + return 0;
|
| + // It's possible to have hash collisions between arbitrary strings and
|
| + // known identifiers (e.g. "bvvfg" collides with "script").
|
| + // However ASSERTs in StringImpl::createStatic guard against there ever being collisions
|
| + // between static strings.
|
| + if (!equal(it->value, characters, length))
|
| + return 0;
|
| + return it->value;
|
| }
|
|
|
| }
|
|
|