| 538 | } // namespace |
| 539 | |
| 540 | absl::Cord ByteString::ToCord() const& { |
| 541 | switch (GetKind()) { |
| 542 | case ByteStringKind::kSmall: |
| 543 | return absl::Cord(GetSmall()); |
| 544 | case ByteStringKind::kMedium: { |
| 545 | const auto* refcount = GetMediumReferenceCount(); |
| 546 | if (refcount != nullptr) { |
| 547 | StrongRef(*refcount); |
| 548 | return absl::MakeCordFromExternal(GetMedium(), |
| 549 | ReferenceCountReleaser{refcount}); |
| 550 | } |
| 551 | return absl::Cord(GetMedium()); |
| 552 | } |
| 553 | case ByteStringKind::kLarge: |
| 554 | return GetLarge(); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | absl::Cord ByteString::ToCord() && { |
| 559 | switch (GetKind()) { |