| 727 | } |
| 728 | |
| 729 | void ByteString::CopyFrom(const ByteString& other) { |
| 730 | ABSL_DCHECK_NE(&other, this); |
| 731 | |
| 732 | switch (other.GetKind()) { |
| 733 | case ByteStringKind::kSmall: |
| 734 | switch (GetKind()) { |
| 735 | case ByteStringKind::kSmall: |
| 736 | break; |
| 737 | case ByteStringKind::kMedium: |
| 738 | DestroyMedium(); |
| 739 | break; |
| 740 | case ByteStringKind::kLarge: |
| 741 | DestroyLarge(); |
| 742 | break; |
| 743 | } |
| 744 | rep_.small = other.rep_.small; |
| 745 | break; |
| 746 | case ByteStringKind::kMedium: |
| 747 | switch (GetKind()) { |
| 748 | case ByteStringKind::kSmall: |
| 749 | rep_.medium = other.rep_.medium; |
| 750 | StrongRef(GetMediumReferenceCount()); |
| 751 | break; |
| 752 | case ByteStringKind::kMedium: |
| 753 | StrongRef(other.GetMediumReferenceCount()); |
| 754 | DestroyMedium(); |
| 755 | rep_.medium = other.rep_.medium; |
| 756 | break; |
| 757 | case ByteStringKind::kLarge: |
| 758 | DestroyLarge(); |
| 759 | rep_.medium = other.rep_.medium; |
| 760 | StrongRef(GetMediumReferenceCount()); |
| 761 | break; |
| 762 | } |
| 763 | break; |
| 764 | case ByteStringKind::kLarge: |
| 765 | switch (GetKind()) { |
| 766 | case ByteStringKind::kSmall: |
| 767 | SetLarge(other.GetLarge()); |
| 768 | break; |
| 769 | case ByteStringKind::kMedium: |
| 770 | DestroyMedium(); |
| 771 | SetLarge(other.GetLarge()); |
| 772 | break; |
| 773 | case ByteStringKind::kLarge: |
| 774 | GetLarge() = other.GetLarge(); |
| 775 | break; |
| 776 | } |
| 777 | break; |
| 778 | } |
| 779 | } |
| 780 | |
| 781 | void ByteString::MoveFrom(ByteString& other) { |
| 782 | ABSL_DCHECK_NE(&other, this); |