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

Function AppendMapHeader

msgp/write_bytes.go:26–41  ·  view source on GitHub ↗

AppendMapHeader appends a map header with the given size to the slice

(b []byte, sz uint32)

Source from the content-addressed store, hash-verified

24// AppendMapHeader appends a map header with the
25// given size to the slice
26func AppendMapHeader(b []byte, sz uint32) []byte {
27 switch {
28 case sz <= 15:
29 return append(b, wfixmap(uint8(sz)))
30
31 case sz <= math.MaxUint16:
32 o, n := ensure(b, 3)
33 prefixu16(o[n:], mmap16, uint16(sz))
34 return o
35
36 default:
37 o, n := ensure(b, 5)
38 prefixu32(o[n:], mmap32, sz)
39 return o
40 }
41}
42
43// AppendArrayHeader appends an array header with
44// the given size to the slice

Callers 15

gStructMethod · 0.92
fixedsizeExprFunction · 0.92
mapstructMethod · 0.92
structmapMethod · 0.92
mainFunction · 0.92
TestMapLimitEnforcementFunction · 0.92
TestSliceLimitsAppliedFunction · 0.92
TestNestedArrayLimitsFunction · 0.92
TestMapExceedsLimitFunction · 0.92
TestStructLevelLimitsFunction · 0.92

Calls 4

wfixmapFunction · 0.85
prefixu16Function · 0.85
prefixu32Function · 0.85
ensureFunction · 0.70

Tested by 15

TestMapLimitEnforcementFunction · 0.74
TestSliceLimitsAppliedFunction · 0.74
TestNestedArrayLimitsFunction · 0.74
TestMapExceedsLimitFunction · 0.74
TestStructLevelLimitsFunction · 0.74
TestAllowNilZeroCopyFunction · 0.74

Used in the wild real call sites across dependent graphs

searching dependent graphs…