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

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

Issue 2241573004: Use StringView for String::replace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: woops. 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/StringImpl.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 21820eadd34e7504c3a35e84982876f76db51ef1..f4e529e04ad32f520f34d46c544157a500435156 100644
--- a/third_party/WebKit/Source/wtf/text/WTFString.h
+++ b/third_party/WebKit/Source/wtf/text/WTFString.h
@@ -219,36 +219,30 @@ public:
void append(UChar);
void insert(const StringView&, unsigned pos);
- String& replace(UChar a, UChar b)
+ // TODO(esprehn): replace strangely both modifies this String *and* return a
+ // value. It should only do one of those.
+ String& replace(UChar pattern, UChar replacement)
{
if (m_impl)
- m_impl = m_impl->replace(a, b);
+ m_impl = m_impl->replace(pattern, replacement);
return *this;
}
- String& replace(UChar a, const String& b)
+ String& replace(UChar pattern, const StringView& replacement)
{
if (m_impl)
- m_impl = m_impl->replace(a, b.impl());
+ m_impl = m_impl->replace(pattern, replacement);
return *this;
}
- String& replace(const String& a, const String& b)
+ String& replace(const StringView& pattern, const StringView& replacement)
{
if (m_impl)
- m_impl = m_impl->replace(a.impl(), b.impl());
+ m_impl = m_impl->replace(pattern, replacement);
return *this;
}
- String& replace(unsigned index, unsigned len, const String& b)
+ String& replace(unsigned index, unsigned lengthToReplace, const StringView& replacement)
{
if (m_impl)
- m_impl = m_impl->replace(index, len, b.impl());
- return *this;
- }
-
- ALWAYS_INLINE String& replace(UChar a, const char* characters)
- {
- ASSERT(characters);
- if (m_impl)
- m_impl = m_impl->replace(a, characters, strlen(characters));
+ m_impl = m_impl->replace(index, lengthToReplace, replacement);
return *this;
}
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698