Chromium Code Reviews| 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..7335f3976bbfa35eafe78d5e6f44a6791117f97a 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* findAtomizedStringIfKnown(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 addNames() guard against there ever being collisions |
|
abarth-chromium
2013/12/10 04:48:23
addNames? Does that function exist anymore?
oystein (OOO til 10th of July)
2013/12/10 18:42:27
Updated comment.
|
| + // between known identifiers. |
| + if (!equal(it->value, characters, length)) |
| + return 0; |
| + return it->value; |
| } |
| } |