| 959 | } |
| 960 | |
| 961 | void ByteString::SetMedium(google::protobuf::Arena* absl_nullable arena, |
| 962 | absl::string_view string) { |
| 963 | ABSL_DCHECK_GT(string.size(), kSmallByteStringCapacity); |
| 964 | rep_.header.kind = ByteStringKind::kMedium; |
| 965 | rep_.medium.size = string.size(); |
| 966 | if (arena != nullptr) { |
| 967 | char* data = static_cast<char*>( |
| 968 | arena->AllocateAligned(rep_.medium.size, alignof(char))); |
| 969 | std::memcpy(data, string.data(), rep_.medium.size); |
| 970 | rep_.medium.data = data; |
| 971 | rep_.medium.owner = |
| 972 | reinterpret_cast<uintptr_t>(arena) | kMetadataOwnerArenaBit; |
| 973 | } else { |
| 974 | auto pair = MakeReferenceCountedString(string); |
| 975 | rep_.medium.data = pair.second.data(); |
| 976 | rep_.medium.owner = reinterpret_cast<uintptr_t>(pair.first) | |
| 977 | kMetadataOwnerReferenceCountBit; |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | void ByteString::SetExternalMedium(absl::string_view string) { |
| 982 | ABSL_DCHECK_GT(string.size(), kSmallByteStringCapacity); |
nothing calls this directly
no test coverage detected