MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / SetMedium

Method SetMedium

common/internal/byte_string.cc:961–979  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

959}
960
961void 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
981void ByteString::SetExternalMedium(absl::string_view string) {
982 ABSL_DCHECK_GT(string.size(), kSmallByteStringCapacity);

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45

Tested by

no test coverage detected