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

Method MarshalMsg

msgp/setof/generated.go:309–322  ·  view source on GitHub ↗

MarshalMsg encodes the message to the bytes.

(bytes []byte)

Source from the content-addressed store, hash-verified

307
308// MarshalMsg encodes the message to the bytes.
309func (s Int) MarshalMsg(bytes []byte) ([]byte, error) {
310 if s == nil {
311 return msgp.AppendNil(bytes), nil
312 }
313 if len(s) == 0 {
314 return msgp.AppendArrayHeader(bytes, 0), nil
315 }
316 bytes = ensure(bytes, s.Msgsize())
317 bytes = msgp.AppendArrayHeader(bytes, uint32(len(s)))
318 for k := range s {
319 bytes = msgp.AppendInt(bytes, int(k))
320 }
321 return bytes, nil
322}
323
324// AsSlice returns the set as a slice.
325func (s Int) AsSlice() []int {

Callers 1

TestInt_NilHandlingFunction · 0.95

Calls 5

MsgsizeMethod · 0.95
AppendNilFunction · 0.92
AppendArrayHeaderFunction · 0.92
AppendIntFunction · 0.92
ensureFunction · 0.70

Tested by 1

TestInt_NilHandlingFunction · 0.76