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

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

Issue 2148423003: Use StringView for equalIgnoringCase. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add rebaselines. Created 4 years, 4 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 115ac20684b447eec920379a9a37b18cf09384fb..e87ce51218a18ac154ac9bea79420cf17ac85eee 100644
--- a/third_party/WebKit/Source/wtf/text/StringView.cpp
+++ b/third_party/WebKit/Source/wtf/text/StringView.cpp
@@ -63,6 +63,28 @@ bool equalStringView(const StringView& a, const StringView& b)
return equal(a.characters16(), b.characters16(), a.length());
}
+
+bool equalIgnoringCaseAndNullity(const StringView& a, const StringView& b)
+{
haraken 2016/08/04 09:05:28 Can we add: DCHECK(!a.isNull()); DCHECK(!b.is
esprehn 2016/08/04 18:30:07 No since the semantics are that you still allow nu
+ if (a.length() != b.length())
+ return false;
+ if (a.is8Bit()) {
+ if (b.is8Bit())
+ return equalIgnoringCase(a.characters8(), b.characters8(), a.length());
+ return equalIgnoringCase(a.characters8(), b.characters16(), a.length());
+ }
+ if (b.is8Bit())
+ return equalIgnoringCase(a.characters16(), b.characters8(), a.length());
+ return equalIgnoringCase(a.characters16(), b.characters16(), a.length());
+}
+
+bool equalIgnoringCase(const StringView& a, const StringView& b)
+{
+ if (a.isNull() || b.isNull())
+ return a.isNull() == b.isNull();
+ return equalIgnoringCaseAndNullity(a, b);
+}
+
bool equalIgnoringASCIICase(const StringView& a, const StringView& b)
{
if (a.isNull() || b.isNull())

Powered by Google App Engine
This is Rietveld 408576698