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

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: 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 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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 size_t tail = size - (offset + length); 613 size_t tail = size - (offset + length);
614 if (tail) { 614 if (tail) {
615 memcpy(dst + offset, src + (offset + length), tail); 615 memcpy(dst + offset, src + (offset + length), tail);
616 } 616 }
617 SkASSERT(dst[tmp.size()] == 0); 617 SkASSERT(dst[tmp.size()] == 0);
618 this->swap(tmp); 618 this->swap(tmp);
619 } 619 }
620 } 620 }
621 } 621 }
622 622
623 void SkString::replace(SkUnichar oldChar, SkUnichar newChar) {
624 for (size_t i = 0; i < size(); ++i) {
625 if (oldChar == this->operator[](i)) {
626 this->operator[](i) = newChar;
627 }
628 }
629 }
630
623 void SkString::swap(SkString& other) { 631 void SkString::swap(SkString& other) {
624 this->validate(); 632 this->validate();
625 other.validate(); 633 other.validate();
626 634
627 SkTSwap<Rec*>(fRec, other.fRec); 635 SkTSwap<Rec*>(fRec, other.fRec);
628 #ifdef SK_DEBUG 636 #ifdef SK_DEBUG
629 SkTSwap<const char*>(fStr, other.fStr); 637 SkTSwap<const char*>(fStr, other.fStr);
630 #endif 638 #endif
631 } 639 }
632 640
(...skipping 14 matching lines...) Expand all
647 const size_t len = strcspn(str, delimiters); 655 const size_t len = strcspn(str, delimiters);
648 out->push_back().set(str, len); 656 out->push_back().set(str, len);
649 str += len; 657 str += len;
650 // Skip any delimiters. 658 // Skip any delimiters.
651 str += strspn(str, delimiters); 659 str += strspn(str, delimiters);
652 } 660 }
653 } 661 }
654 662
655 #undef VSNPRINTF 663 #undef VSNPRINTF
656 #undef SNPRINTF 664 #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