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

Unified Diff: third_party/WebKit/Source/wtf/text/StringView.cpp

Issue 2024373002: Replace CSSParserString with StringView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Match arguments to equalStringView. Created 4 years, 7 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: third_party/WebKit/Source/wtf/text/StringView.cpp
diff --git a/third_party/WebKit/Source/wtf/text/StringView.cpp b/third_party/WebKit/Source/wtf/text/StringView.cpp
index fea433c4225f1e65ed72158902949d58be54a75f..6135d8d258118808288766b95b247f8f5c0df942 100644
--- a/third_party/WebKit/Source/wtf/text/StringView.cpp
+++ b/third_party/WebKit/Source/wtf/text/StringView.cpp
@@ -32,15 +32,15 @@ String StringView::toString() const
return emptyString();
if (is8Bit())
return String(m_data.characters8, m_length);
- return String(m_data.characters16, m_length);
+ return StringImpl::create8BitIfPossible(m_data.characters16, m_length);
}
bool equalStringView(const StringView& a, const StringView& b)
{
+ if (a.isNull() || b.isNull())
+ return a.isNull() == b.isNull();
if (a.length() != b.length())
return false;
- if (a.isEmpty() || b.isEmpty())
- return a.isEmpty() == b.isEmpty();
if (a.is8Bit()) {
if (b.is8Bit())
return equal(a.characters8(), b.characters8(), a.length());
@@ -51,4 +51,20 @@ bool equalStringView(const StringView& a, const StringView& b)
return equal(a.characters16(), b.characters16(), a.length());
}
+bool equalIgnoringASCIICase(const StringView& a, const StringView& b)
+{
+ if (a.isNull() || b.isNull())
+ return a.isNull() == b.isNull();
+ if (a.length() != b.length())
+ return false;
+ if (a.is8Bit()) {
+ if (b.is8Bit())
+ return equalIgnoringASCIICase(a.characters8(), b.characters8(), a.length());
+ return equalIgnoringASCIICase(a.characters8(), b.characters16(), a.length());
+ }
+ if (b.is8Bit())
+ return equalIgnoringASCIICase(a.characters16(), b.characters8(), a.length());
+ return equalIgnoringASCIICase(a.characters16(), b.characters16(), a.length());
+}
+
} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringView.h ('k') | third_party/WebKit/Source/wtf/text/StringViewTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698