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

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: Rebased after MediaFeature generation landed Created 6 years, 10 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
Index: Source/core/html/parser/HTMLParserIdioms.cpp
diff --git a/Source/core/html/parser/HTMLParserIdioms.cpp b/Source/core/html/parser/HTMLParserIdioms.cpp
index e3b143aaf2181cc7646c1968f6c36a489a533fee..14c6eb6ffa6b6d9e2adaa2a85a3612b6878395a4 100644
--- a/Source/core/html/parser/HTMLParserIdioms.cpp
+++ b/Source/core/html/parser/HTMLParserIdioms.cpp
@@ -374,7 +374,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())
@@ -396,4 +397,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;
+}
+
}
« Source/core/css/MediaQueryExp.cpp ('K') | « Source/core/html/parser/HTMLParserIdioms.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698