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

Function AppendBytes

msgp/write_bytes.go:193–212  ·  view source on GitHub ↗

AppendBytes appends bytes to the slice as MessagePack 'bin' data

(b []byte, bts []byte)

Source from the content-addressed store, hash-verified

191
192// AppendBytes appends bytes to the slice as MessagePack 'bin' data
193func AppendBytes(b []byte, bts []byte) []byte {
194 sz := len(bts)
195 var o []byte
196 var n int
197 switch {
198 case sz <= math.MaxUint8:
199 o, n = ensure(b, 2+sz)
200 prefixu8(o[n:], mbin8, uint8(sz))
201 n += 2
202 case sz <= math.MaxUint16:
203 o, n = ensure(b, 3+sz)
204 prefixu16(o[n:], mbin16, uint16(sz))
205 n += 3
206 default:
207 o, n = ensure(b, 5+sz)
208 prefixu32(o[n:], mbin32, uint32(sz))
209 n += 5
210 }
211 return o[:n+copy(o[n:], bts)]
212}
213
214// AppendBytesHeader appends an 'bin' header with
215// the given size to the slice.

Callers 10

MarshalMsgMethod · 0.92
TestAllowNilZeroCopyFunction · 0.92
benchBytesFunction · 0.85
AppendIntfFunction · 0.85
TestAppendBytesFunction · 0.85
benchappendBytesFunction · 0.85

Calls 4

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

Tested by 9

MarshalMsgMethod · 0.74
TestAllowNilZeroCopyFunction · 0.74
benchBytesFunction · 0.68
TestAppendBytesFunction · 0.68
benchappendBytesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…