OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 |
OLD | NEW |