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

Side by Side 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: bad... Created 6 years, 1 month 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
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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 size_t tail = size - (offset + length); 621 size_t tail = size - (offset + length);
622 if (tail) { 622 if (tail) {
623 memcpy(dst + offset, src + (offset + length), tail); 623 memcpy(dst + offset, src + (offset + length), tail);
624 } 624 }
625 SkASSERT(dst[tmp.size()] == 0); 625 SkASSERT(dst[tmp.size()] == 0);
626 this->swap(tmp); 626 this->swap(tmp);
627 } 627 }
628 } 628 }
629 } 629 }
630 630
631 void SkString::replace(SkUnichar oldChar, SkUnichar newChar) {
632 char buffer[kMaxBytesInUTF8Sequence];
633 size_t len = SkUTF8_FromUnichar(oldChar, buffer);
tfarina 2014/11/12 01:41:34 Mike, could you help me here? I'm getting the fol
634
635 if (len) {
636 }
637
638 for (size_t i = 0; i < size(); ++i) {
639 if (oldChar == this->operator[](i)) {
640 this->operator[](i) = newChar;
641 }
642 }
643 }
644
631 void SkString::swap(SkString& other) { 645 void SkString::swap(SkString& other) {
632 this->validate(); 646 this->validate();
633 other.validate(); 647 other.validate();
634 648
635 SkTSwap<Rec*>(fRec, other.fRec); 649 SkTSwap<Rec*>(fRec, other.fRec);
636 #ifdef SK_DEBUG 650 #ifdef SK_DEBUG
637 SkTSwap<const char*>(fStr, other.fStr); 651 SkTSwap<const char*>(fStr, other.fStr);
638 #endif 652 #endif
639 } 653 }
640 654
(...skipping 15 matching lines...) Expand all
656 const size_t len = strcspn(str, delimiters); 670 const size_t len = strcspn(str, delimiters);
657 out->push_back().set(str, len); 671 out->push_back().set(str, len);
658 str += len; 672 str += len;
659 // Skip any delimiters. 673 // Skip any delimiters.
660 str += strspn(str, delimiters); 674 str += strspn(str, delimiters);
661 } 675 }
662 } 676 }
663 677
664 #undef VSNPRINTF 678 #undef VSNPRINTF
665 #undef SNPRINTF 679 #undef SNPRINTF
OLDNEW
« 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