Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Unified Diff: Source/core/html/parser/HTMLParserIdioms.cpp

Issue 178803006: Turn MQ classes into thread safe (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Removed StringImpl comparison atomic check Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/html/parser/HTMLParserIdioms.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLParserIdioms.cpp
diff --git a/Source/core/html/parser/HTMLParserIdioms.cpp b/Source/core/html/parser/HTMLParserIdioms.cpp
index c6fd8dc95c6f44abaefbea327ae141f14bc5fbd7..a71d9a54fac468194b7e3214334c3b4862f4ca14 100644
--- a/Source/core/html/parser/HTMLParserIdioms.cpp
+++ b/Source/core/html/parser/HTMLParserIdioms.cpp
@@ -369,7 +369,8 @@ bool threadSafeMatch(const String& localName, const QualifiedName& qName)
return threadSafeEqual(localName.impl(), qName.localName().impl());
}
-StringImpl* findStringIfStatic(const UChar* characters, unsigned length)
+template<typename CharType>
+inline StringImpl* findStringIfStatic(const CharType* characters, unsigned length)
{
// We don't need to try hashing if we know the string is too long.
if (length > StringImpl::highestStaticStringLength())
@@ -391,4 +392,27 @@ StringImpl* findStringIfStatic(const UChar* characters, unsigned length)
return it->value;
}
+String attemptStaticStringCreation(const LChar* characters, size_t size)
+{
+ String string(findStringIfStatic(characters, size));
+ if (string.impl())
+ return string;
+ return String(characters, size);
+}
+
+String attemptStaticStringCreation(const UChar* characters, size_t size, CharacterWidth width)
+{
+ String string(findStringIfStatic(characters, size));
+ if (string.impl())
+ return string;
+ if (width == Likely8Bit)
+ string = StringImpl::create8BitIfPossible(characters, size);
+ else if (width == Force8Bit)
+ string = String::make8BitFrom16BitSource(characters, size);
+ else
+ string = String(characters, size);
+
+ return string;
+}
+
}
« no previous file with comments | « Source/core/html/parser/HTMLParserIdioms.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698