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 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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 |
OLD | NEW |