| 575 | } |
| 576 | |
| 577 | void ByteString::CopyToCord(absl::Cord* absl_nonnull out) const { |
| 578 | ABSL_DCHECK(out != nullptr); |
| 579 | |
| 580 | switch (GetKind()) { |
| 581 | case ByteStringKind::kSmall: |
| 582 | *out = absl::Cord(GetSmall()); |
| 583 | break; |
| 584 | case ByteStringKind::kMedium: { |
| 585 | const auto* refcount = GetMediumReferenceCount(); |
| 586 | if (refcount != nullptr) { |
| 587 | StrongRef(*refcount); |
| 588 | *out = absl::MakeCordFromExternal(GetMedium(), |
| 589 | ReferenceCountReleaser{refcount}); |
| 590 | } else { |
| 591 | *out = absl::Cord(GetMedium()); |
| 592 | } |
| 593 | } break; |
| 594 | case ByteStringKind::kLarge: |
| 595 | *out = GetLarge(); |
| 596 | break; |
| 597 | } |
| 598 | } |
| 599 | |
| 600 | void ByteString::AppendToCord(absl::Cord* absl_nonnull out) const { |
| 601 | ABSL_DCHECK(out != nullptr); |