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

Unified Diff: src/core/SkString.cpp

Issue 646213002: Eliminate one copy of replace_char() function. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add another test with some weird characters Created 6 years, 2 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: src/core/SkString.cpp
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp
index 48459dbbd8ac69eabb6f2f72cbbf1c9ff862e7f5..db85d188a5432e4bbb15867077877ff3fc0b8174 100644
--- a/src/core/SkString.cpp
+++ b/src/core/SkString.cpp
@@ -620,6 +620,14 @@ void SkString::remove(size_t offset, size_t length) {
}
}
+void SkString::replace(SkUnichar oldChar, SkUnichar newChar) {
+ for (size_t i = 0; i < size(); ++i) {
+ if (oldChar == this->operator[](i)) {
+ this->operator[](i) = newChar;
+ }
+ }
+}
+
void SkString::swap(SkString& other) {
this->validate();
other.validate();
« no previous file with comments | « include/core/SkString.h ('k') | tests/StringTest.cpp » ('j') | tests/StringTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698