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

Unified Diff: Source/wtf/text/StringImpl.cpp

Issue 304273003: Simplify & optimize StringImpl::replace(UChar, UChar) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/text/StringImpl.cpp
diff --git a/Source/wtf/text/StringImpl.cpp b/Source/wtf/text/StringImpl.cpp
index 5ce696e6354139aa56c3b1c093936a01c6d4f39c..838b6715fcdce7c992b8a90e4fcfaab69c36ac77 100644
--- a/Source/wtf/text/StringImpl.cpp
+++ b/Source/wtf/text/StringImpl.cpp
@@ -1529,20 +1529,12 @@ PassRefPtr<StringImpl> StringImpl::replace(UChar oldC, UChar newC)
{
if (oldC == newC)
return this;
- unsigned i;
- for (i = 0; i != m_length; ++i) {
- UChar c = is8Bit() ? characters8()[i] : characters16()[i];
- if (c == oldC)
- break;
- }
- if (i == m_length)
+
+ if (find(oldC) == kNotFound)
return this;
+ unsigned i;
if (is8Bit()) {
- if (oldC > 0xff)
- // Looking for a 16 bit char in an 8 bit string, we're done.
- return this;
-
if (newC <= 0xff) {
LChar* data;
LChar oldChar = static_cast<LChar>(oldC);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698