MCPcopy Index your code
hub / github.com/tinylib/msgp / AppendArray

Function AppendArray

msgp/iter.go:201–213  ·  view source on GitHub ↗

AppendArray writes an array to the provided buffer. The writeFn parameter specifies the function to use to write each element of the array. The returned buffer contains the encoded array. The function panics if the array is larger than math.MaxUint32 elements.

(b []byte, a []T, writeFn func(b []byte, v T) []byte)

Source from the content-addressed store, hash-verified

199// The returned buffer contains the encoded array.
200// The function panics if the array is larger than math.MaxUint32 elements.
201func AppendArray[T any](b []byte, a []T, writeFn func(b []byte, v T) []byte) []byte {
202 if a == nil {
203 return AppendNil(b)
204 }
205 if uint64(len(a)) > math.MaxUint32 {
206 panic(fmt.Sprintf("array too large to encode: %d elements", len(a)))
207 }
208 b = AppendArrayHeader(b, uint32(len(a)))
209 for _, v := range a {
210 b = writeFn(b, v)
211 }
212 return b
213}
214
215// ReadMapBytes returns an iterator over key/value
216// pairs from a MessagePack map encoded in b.

Callers 2

ExampleReadArrayBytesFunction · 0.85

Calls 2

AppendNilFunction · 0.85
AppendArrayHeaderFunction · 0.85

Tested by 2

ExampleReadArrayBytesFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…