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

Side by Side 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 unified diff | Download patch
« include/core/SkString.h ('K') | « include/core/SkString.h ('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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkString.h" 10 #include "SkString.h"
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 SkASSERT(p >= buffer); 548 SkASSERT(p >= buffer);
549 this->insert(offset, p, buffer + sizeof(buffer) - p); 549 this->insert(offset, p, buffer + sizeof(buffer) - p);
550 } 550 }
551 551
552 void SkString::insertScalar(size_t offset, SkScalar value) { 552 void SkString::insertScalar(size_t offset, SkScalar value) {
553 char buffer[SkStrAppendScalar_MaxSize]; 553 char buffer[SkStrAppendScalar_MaxSize];
554 char* stop = SkStrAppendScalar(buffer, value); 554 char* stop = SkStrAppendScalar(buffer, value);
555 this->insert(offset, buffer, stop - buffer); 555 this->insert(offset, buffer, stop - buffer);
556 } 556 }
557 557
558 void SkString::replace_char(const char oldChar, const char newChar) {
559 if (this->isEmpty()) {
560 return;
561 }
562 for (size_t i = 0; i < this->size(); ++i) {
563 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 >
564 fRec->data()[i] = newChar;
565 }
566 }
567 }
568
558 void SkString::printf(const char format[], ...) { 569 void SkString::printf(const char format[], ...) {
559 char buffer[kBufferSize]; 570 char buffer[kBufferSize];
560 ARGS_TO_BUFFER(format, buffer, kBufferSize); 571 ARGS_TO_BUFFER(format, buffer, kBufferSize);
561 572
562 this->set(buffer, strlen(buffer)); 573 this->set(buffer, strlen(buffer));
563 } 574 }
564 575
565 void SkString::appendf(const char format[], ...) { 576 void SkString::appendf(const char format[], ...) {
566 char buffer[kBufferSize]; 577 char buffer[kBufferSize];
567 ARGS_TO_BUFFER(format, buffer, kBufferSize); 578 ARGS_TO_BUFFER(format, buffer, kBufferSize);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 const size_t len = strcspn(str, delimiters); 652 const size_t len = strcspn(str, delimiters);
642 out->push_back().set(str, len); 653 out->push_back().set(str, len);
643 str += len; 654 str += len;
644 // Skip any delimiters. 655 // Skip any delimiters.
645 str += strspn(str, delimiters); 656 str += strspn(str, delimiters);
646 } 657 }
647 } 658 }
648 659
649 #undef VSNPRINTF 660 #undef VSNPRINTF
650 #undef SNPRINTF 661 #undef SNPRINTF
OLDNEW
« 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