MCPcopy Create free account
hub / github.com/apache/fory / write_encoded_meta_string

Function write_encoded_meta_string

cpp/fory/serialization/context.cc:131–148  ·  view source on GitHub ↗

write pre-encoded meta string to buffer (avoids re-encoding on each write)

Source from the content-addressed store, hash-verified

129
130/// write pre-encoded meta string to buffer (avoids re-encoding on each write)
131static void write_encoded_meta_string(Buffer &buffer,
132 const CachedMetaString &encoded) {
133 const uint32_t encoded_len = static_cast<uint32_t>(encoded.bytes.size());
134 uint32_t header = encoded_len << 1; // last bit 0 => new string
135 buffer.write_var_uint32(header);
136
137 if (encoded_len > k_small_string_threshold) {
138 // For large strings, write pre-computed hash
139 buffer.write_int64(encoded.hash);
140 } else if (encoded_len > 0) {
141 // For small strings, write encoding byte
142 buffer.write_int8(static_cast<int8_t>(encoded.encoding));
143 }
144
145 if (encoded_len > 0) {
146 buffer.write_bytes(encoded.bytes.data(), encoded_len);
147 }
148}
149
150Result<void, Error>
151WriteContext::write_enum_type_info(const std::type_index &type) {

Callers 3

write_enum_type_infoMethod · 0.85
write_any_type_infoMethod · 0.85

Calls 6

sizeMethod · 0.45
write_var_uint32Method · 0.45
write_int64Method · 0.45
write_int8Method · 0.45
write_bytesMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected