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

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

Issue 171383002: A thread-safe Media Query Parser (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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.h
diff --git a/Source/core/html/parser/HTMLParserIdioms.h b/Source/core/html/parser/HTMLParserIdioms.h
index 49dbed3ba6c6639e80eff7daa5847e36dc3b8b1c..a128d4fb876cca424259c1c157873cf9d11b1fce 100644
--- a/Source/core/html/parser/HTMLParserIdioms.h
+++ b/Source/core/html/parser/HTMLParserIdioms.h
@@ -115,21 +115,33 @@ enum CharacterWidth {
Force16Bit
};
-template<size_t inlineCapacity>
-static String attemptStaticStringCreation(const Vector<UChar, inlineCapacity>& vector, CharacterWidth width)
+inline static String attemptStaticStringCreation(const UChar* characters, size_t size, CharacterWidth width)
{
- String string(findStringIfStatic(vector.data(), vector.size()));
+ String string(findStringIfStatic(characters, size));
if (string.impl())
return string;
if (width == Likely8Bit)
- string = StringImpl::create8BitIfPossible(vector);
+ string = StringImpl::create8BitIfPossible(characters, size);
else if (width == Force8Bit)
- string = String::make8BitFrom16BitSource(vector);
+ string = String::make8BitFrom16BitSource(characters, size);
else
- string = String(vector);
+ string = String(characters, size);
return string;
}
+template<size_t inlineCapacity>
+static String attemptStaticStringCreation(const Vector<UChar, inlineCapacity>& vector, CharacterWidth width)
+{
+ return attemptStaticStringCreation(vector.data(), vector.size(), width);
+}
+
+inline static String attemptStaticStringCreation(const String str, CharacterWidth width)
+{
+ ASSERT(!str.is8Bit());
+ return attemptStaticStringCreation(str.characters16(), str.length(), width);
+}
+
+
}
#endif

Powered by Google App Engine
This is Rietveld 408576698