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

Unified Diff: src/core/SkString.cpp

Issue 322253005: add replace_char() method to SkString API (skbug.com/2651) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 6 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
« include/core/SkString.h ('K') | « include/core/SkString.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkString.cpp
diff --git a/src/core/SkString.cpp b/src/core/SkString.cpp
index ba1da4136893dffcbc5e1ac8252d9e3a4118a977..aeff325dca202a04d8e4b395092d960eef17aed9 100644
--- a/src/core/SkString.cpp
+++ b/src/core/SkString.cpp
@@ -555,6 +555,17 @@ void SkString::insertScalar(size_t offset, SkScalar value) {
this->insert(offset, buffer, stop - buffer);
}
+void SkString::replace_char(const char oldChar, const char newChar) {
+ if (this->isEmpty()) {
+ return;
+ }
+ for (size_t i = 0; i < this->size(); ++i) {
+ if (oldChar == this->operator[](i)) {
epoger 2014/06/11 11:01:33 Instead of going through the [] operator, I suspec
rs.prinja 2014/06/11 12:08:03 Done, although since unsigned always compares as >
+ fRec->data()[i] = newChar;
+ }
+ }
+}
+
void SkString::printf(const char format[], ...) {
char buffer[kBufferSize];
ARGS_TO_BUFFER(format, buffer, kBufferSize);
« include/core/SkString.h ('K') | « include/core/SkString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698