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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 { return m_impl ? DISPATCH_CASE_OP(caseSensitivity, m_impl->endsWith, (s uffix)) : suffix.isEmpty(); } 212 { return m_impl ? DISPATCH_CASE_OP(caseSensitivity, m_impl->endsWith, (s uffix)) : suffix.isEmpty(); }
213 bool endsWith(UChar character) const 213 bool endsWith(UChar character) const
214 { return m_impl ? m_impl->endsWith(character) : false; } 214 { return m_impl ? m_impl->endsWith(character) : false; }
215 215
216 void append(const StringView&); 216 void append(const StringView&);
217 void append(LChar); 217 void append(LChar);
218 void append(char c) { append(static_cast<LChar>(c)); } 218 void append(char c) { append(static_cast<LChar>(c)); }
219 void append(UChar); 219 void append(UChar);
220 void insert(const StringView&, unsigned pos); 220 void insert(const StringView&, unsigned pos);
221 221
222 String& replace(UChar a, UChar b) 222 // TODO(esprehn): replace strangely both modifies this String *and* return a
223 // value. It should only do one of those.
224 String& replace(UChar pattern, UChar replacement)
223 { 225 {
224 if (m_impl) 226 if (m_impl)
225 m_impl = m_impl->replace(a, b); 227 m_impl = m_impl->replace(pattern, replacement);
226 return *this; 228 return *this;
227 } 229 }
228 String& replace(UChar a, const String& b) 230 String& replace(UChar pattern, const StringView& replacement)
229 { 231 {
230 if (m_impl) 232 if (m_impl)
231 m_impl = m_impl->replace(a, b.impl()); 233 m_impl = m_impl->replace(pattern, replacement);
232 return *this; 234 return *this;
233 } 235 }
234 String& replace(const String& a, const String& b) 236 String& replace(const StringView& pattern, const StringView& replacement)
235 { 237 {
236 if (m_impl) 238 if (m_impl)
237 m_impl = m_impl->replace(a.impl(), b.impl()); 239 m_impl = m_impl->replace(pattern, replacement);
238 return *this; 240 return *this;
239 } 241 }
240 String& replace(unsigned index, unsigned len, const String& b) 242 String& replace(unsigned index, unsigned lengthToReplace, const StringView& replacement)
241 { 243 {
242 if (m_impl) 244 if (m_impl)
243 m_impl = m_impl->replace(index, len, b.impl()); 245 m_impl = m_impl->replace(index, lengthToReplace, replacement);
244 return *this; 246 return *this;
245 } 247 }
246 248
247 ALWAYS_INLINE String& replace(UChar a, const char* characters)
248 {
249 ASSERT(characters);
250 if (m_impl)
251 m_impl = m_impl->replace(a, characters, strlen(characters));
252 return *this;
253 }
254
255 void fill(UChar c) 249 void fill(UChar c)
256 { 250 {
257 if (m_impl) 251 if (m_impl)
258 m_impl = m_impl->fill(c); 252 m_impl = m_impl->fill(c);
259 } 253 }
260 254
261 void ensure16Bit(); 255 void ensure16Bit();
262 256
263 void truncate(unsigned len); 257 void truncate(unsigned len);
264 void remove(unsigned pos, int len = 1); 258 void remove(unsigned pos, int len = 1);
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 using WTF::emptyString16Bit; 581 using WTF::emptyString16Bit;
588 using WTF::append; 582 using WTF::append;
589 using WTF::charactersAreAllASCII; 583 using WTF::charactersAreAllASCII;
590 using WTF::equal; 584 using WTF::equal;
591 using WTF::find; 585 using WTF::find;
592 using WTF::isAllSpecialCharacters; 586 using WTF::isAllSpecialCharacters;
593 using WTF::isSpaceOrNewline; 587 using WTF::isSpaceOrNewline;
594 588
595 #include "wtf/text/AtomicString.h" 589 #include "wtf/text/AtomicString.h"
596 #endif // WTFString_h 590 #endif // WTFString_h
OLDNEW
« 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