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

Unified Diff: third_party/WebKit/Source/wtf/text/WTFString.h

Issue 2227903002: String::contains should use StringView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/WTFString.h
diff --git a/third_party/WebKit/Source/wtf/text/WTFString.h b/third_party/WebKit/Source/wtf/text/WTFString.h
index 7fd2772c4a35f2938971d569a9aee46de092842d..25953655260623ad93fb6fd42b9897839cc8d49a 100644
--- a/third_party/WebKit/Source/wtf/text/WTFString.h
+++ b/third_party/WebKit/Source/wtf/text/WTFString.h
@@ -182,6 +182,10 @@ public:
size_t find(const StringView& value, unsigned start = 0, TextCaseSensitivity caseSensitivity = TextCaseSensitive) const
{ return m_impl ? DISPATCH_CASE_OP(caseSensitivity, m_impl->find, (value, start)) : kNotFound; }
+ bool contains(char c) const { return find(c) != kNotFound; }
+ bool contains(const StringView& value, TextCaseSensitivity caseSensitivity = TextCaseSensitive) const
+ { return find(value, 0, caseSensitivity) != kNotFound; }
+
// Find the last instance of a single character or string.
size_t reverseFind(UChar c, unsigned start = UINT_MAX) const
{ return m_impl ? m_impl->reverseFind(c, start) : kNotFound; }
@@ -207,10 +211,6 @@ public:
void prependTo(BufferType&, unsigned pos = 0, unsigned len = UINT_MAX) const;
UChar32 characterStartingAt(unsigned) const;
- template<typename CharacterType>
- bool contains(CharacterType c) const { return find(c) != kNotFound; }
- bool contains(const LChar* str, TextCaseSensitivity caseSensitivity = TextCaseSensitive) const { return find(str, 0, caseSensitivity) != kNotFound; }
- bool contains(const String& str, TextCaseSensitivity caseSensitivity = TextCaseSensitive) const { return find(str, 0, caseSensitivity) != kNotFound; }
bool startsWith(const StringView& prefix, TextCaseSensitivity caseSensitivity = TextCaseSensitive) const
{ return m_impl ? DISPATCH_CASE_OP(caseSensitivity, m_impl->startsWith, (prefix)) : prefix.isEmpty(); }

Powered by Google App Engine
This is Rietveld 408576698