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

Method MarshalMsg

msgp/setof/generated.go:35–48  ·  view source on GitHub ↗

MarshalMsg encodes the message to the bytes.

(bytes []byte)

Source from the content-addressed store, hash-verified

33
34// MarshalMsg encodes the message to the bytes.
35func (s String) MarshalMsg(bytes []byte) ([]byte, error) {
36 if s == nil {
37 return msgp.AppendNil(bytes), nil
38 }
39 if len(s) == 0 {
40 return msgp.AppendArrayHeader(bytes, 0), nil
41 }
42 bytes = ensure(bytes, s.Msgsize())
43 bytes = msgp.AppendArrayHeader(bytes, uint32(len(s)))
44 for k := range s {
45 bytes = msgp.AppendString(bytes, string(k))
46 }
47 return bytes, nil
48}
49
50// AsSlice returns the set as a slice.
51func (s String) AsSlice() []string {

Callers 1

TestString_NilHandlingFunction · 0.95

Calls 5

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

Tested by 1

TestString_NilHandlingFunction · 0.76