MCPcopy
hub / github.com/tinylib/msgp / AppendStringFromBytes

Function AppendStringFromBytes

msgp/write_bytes.go:270–293  ·  view source on GitHub ↗

AppendStringFromBytes appends a []byte as a MessagePack 'str' to the slice 'b.'

(b []byte, str []byte)

Source from the content-addressed store, hash-verified

268// AppendStringFromBytes appends a []byte
269// as a MessagePack 'str' to the slice 'b.'
270func AppendStringFromBytes(b []byte, str []byte) []byte {
271 sz := len(str)
272 var n int
273 var o []byte
274 switch {
275 case sz <= 31:
276 o, n = ensure(b, 1+sz)
277 o[n] = wfixstr(uint8(sz))
278 n++
279 case sz <= math.MaxUint8:
280 o, n = ensure(b, 2+sz)
281 prefixu8(o[n:], mstr8, uint8(sz))
282 n += 2
283 case sz <= math.MaxUint16:
284 o, n = ensure(b, 3+sz)
285 prefixu16(o[n:], mstr16, uint16(sz))
286 n += 3
287 default:
288 o, n = ensure(b, 5+sz)
289 prefixu32(o[n:], mstr32, uint32(sz))
290 n += 5
291 }
292 return o[:n+copy(o[n:], str)]
293}
294
295// AppendComplex64 appends a complex64 to the slice as a MessagePack extension
296func AppendComplex64(b []byte, c complex64) []byte {

Callers

nothing calls this directly

Calls 5

wfixstrFunction · 0.85
prefixu8Function · 0.85
prefixu16Function · 0.85
prefixu32Function · 0.85
ensureFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…