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

Method UnmarshalMsg

msgp/setof/generated.go:1091–1117  ·  view source on GitHub ↗

UnmarshalMsg decodes the message from the bytes.

(bytes []byte)

Source from the content-addressed store, hash-verified

1089
1090// UnmarshalMsg decodes the message from the bytes.
1091func (s *ByteSorted) UnmarshalMsg(bytes []byte) ([]byte, error) {
1092 if msgp.IsNil(bytes) {
1093 *s = nil
1094 return bytes[msgp.NilSize:], nil
1095 }
1096 // Read the array header
1097 sz, bytes, err := msgp.ReadArrayHeaderBytes(bytes)
1098 if err != nil {
1099 return nil, err
1100 }
1101 dst := *s
1102 if dst == nil {
1103 dst = make(ByteSorted, sz)
1104 } else {
1105 clear(dst)
1106 }
1107 for range sz {
1108 var k byte
1109 k, bytes, err = msgp.ReadByteBytes(bytes)
1110 if err != nil {
1111 return nil, err
1112 }
1113 dst[byte(k)] = struct{}{}
1114 }
1115 *s = dst
1116 return bytes, nil
1117}
1118
1119// Msgsize returns the maximum size of the message.
1120func (s ByteSorted) Msgsize() int {

Callers 4

TestByteSorted_RoundTripFunction · 0.95
TestByteSorted_EmptySetFunction · 0.95

Calls 3

IsNilFunction · 0.92
ReadArrayHeaderBytesFunction · 0.92
ReadByteBytesFunction · 0.92

Tested by 4

TestByteSorted_RoundTripFunction · 0.76
TestByteSorted_EmptySetFunction · 0.76