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

Method UnmarshalMsg

msgp/setof/generated.go:1376–1402  ·  view source on GitHub ↗

UnmarshalMsg decodes the message from the bytes.

(bytes []byte)

Source from the content-addressed store, hash-verified

1374
1375// UnmarshalMsg decodes the message from the bytes.
1376func (s *Int8Sorted) UnmarshalMsg(bytes []byte) ([]byte, error) {
1377 if msgp.IsNil(bytes) {
1378 *s = nil
1379 return bytes[msgp.NilSize:], nil
1380 }
1381 // Read the array header
1382 sz, bytes, err := msgp.ReadArrayHeaderBytes(bytes)
1383 if err != nil {
1384 return nil, err
1385 }
1386 dst := *s
1387 if dst == nil {
1388 dst = make(Int8Sorted, sz)
1389 } else {
1390 clear(dst)
1391 }
1392 for range sz {
1393 var k int8
1394 k, bytes, err = msgp.ReadInt8Bytes(bytes)
1395 if err != nil {
1396 return nil, err
1397 }
1398 dst[int8(k)] = struct{}{}
1399 }
1400 *s = dst
1401 return bytes, nil
1402}
1403
1404// Msgsize returns the maximum size of the message.
1405func (s Int8Sorted) Msgsize() int {

Callers 4

TestInt8Sorted_RoundTripFunction · 0.95
TestInt8Sorted_EmptySetFunction · 0.95

Calls 3

IsNilFunction · 0.92
ReadArrayHeaderBytesFunction · 0.92
ReadInt8BytesFunction · 0.92

Tested by 4

TestInt8Sorted_RoundTripFunction · 0.76
TestInt8Sorted_EmptySetFunction · 0.76