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

Function writeString

go/fory/string.go:35–49  ·  view source on GitHub ↗

writeString writes a string to buffer using xlang encoding Optimized to combine header and data writes with single grow() call

(buf *ByteBuffer, value string)

Source from the content-addressed store, hash-verified

33// writeString writes a string to buffer using xlang encoding
34// Optimized to combine header and data writes with single grow() call
35func writeString(buf *ByteBuffer, value string) {
36 data := unsafeGetBytes(value)
37 dataLen := len(data)
38 header := (uint64(dataLen) << 2) | encodingUTF8
39
40 // Reserve space for header (max 5 bytes) + data in one call
41 buf.Reserve(5 + dataLen)
42 // Write header inline
43 buf.WriteVaruint36Small(header)
44 // Write data inline without grow check
45 if dataLen > 0 {
46 copy(buf.data[buf.writerIndex:], data)
47 buf.writerIndex += dataLen
48 }
49}
50
51// readString reads a string from buffer using xlang encoding
52func readString(buf *ByteBuffer, err *Error) string {

Callers 12

writeDataWithGenericsMethod · 0.85
WriteStringSliceFunction · 0.85
WriteDataMethod · 0.85
WriteDataMethod · 0.85
writeMapStringStringFunction · 0.85
writeMapStringInt64Function · 0.85
writeMapStringInt32Function · 0.85
writeMapStringIntFunction · 0.85
writeMapStringFloat64Function · 0.85
writeMapStringBoolFunction · 0.85
writeFastMethod · 0.85
WriteStringMethod · 0.85

Calls 4

unsafeGetBytesFunction · 0.85
WriteVaruint36SmallMethod · 0.80
uint64Function · 0.50
ReserveMethod · 0.45

Tested by

no test coverage detected