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

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: DCHECK is silly. 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
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringView.h ('k') | third_party/WebKit/Source/wtf/text/WTFString.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..be85260fcb985d8c47643f4306036b48b416fa6a 100644
--- a/third_party/WebKit/Source/wtf/text/StringView.cpp
+++ b/third_party/WebKit/Source/wtf/text/StringView.cpp
@@ -5,6 +5,7 @@
#include "wtf/text/StringView.h"
#include "wtf/text/AtomicString.h"
+#include "wtf/text/StringImpl.h"
#include "wtf/text/WTFString.h"
namespace WTF {
@@ -63,6 +64,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)
+{
+ 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())
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringView.h ('k') | third_party/WebKit/Source/wtf/text/WTFString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698