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

Function AppendBytesHeader

msgp/write_bytes.go:216–232  ·  view source on GitHub ↗

AppendBytesHeader appends an 'bin' header with the given size to the slice.

(b []byte, sz uint32)

Source from the content-addressed store, hash-verified

214// AppendBytesHeader appends an 'bin' header with
215// the given size to the slice.
216func AppendBytesHeader(b []byte, sz uint32) []byte {
217 var o []byte
218 var n int
219 switch {
220 case sz <= math.MaxUint8:
221 o, n = ensure(b, 2)
222 prefixu8(o[n:], mbin8, uint8(sz))
223 return o
224 case sz <= math.MaxUint16:
225 o, n = ensure(b, 3)
226 prefixu16(o[n:], mbin16, uint16(sz))
227 return o
228 }
229 o, n = ensure(b, 5)
230 prefixu32(o[n:], mbin32, sz)
231 return o
232}
233
234// AppendBool appends a bool to the slice
235func AppendBool(b []byte, t bool) []byte {

Callers 3

TestAppendBytesHeaderFunction · 0.85

Calls 4

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

Tested by 3

TestAppendBytesHeaderFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…