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

Method UnmarshalMsg

msgp/setof/generated.go:521–547  ·  view source on GitHub ↗

UnmarshalMsg decodes the message from the bytes.

(bytes []byte)

Source from the content-addressed store, hash-verified

519
520// UnmarshalMsg decodes the message from the bytes.
521func (s *IntSorted) UnmarshalMsg(bytes []byte) ([]byte, error) {
522 if msgp.IsNil(bytes) {
523 *s = nil
524 return bytes[msgp.NilSize:], nil
525 }
526 // Read the array header
527 sz, bytes, err := msgp.ReadArrayHeaderBytes(bytes)
528 if err != nil {
529 return nil, err
530 }
531 dst := *s
532 if dst == nil {
533 dst = make(IntSorted, sz)
534 } else {
535 clear(dst)
536 }
537 for range sz {
538 var k int
539 k, bytes, err = msgp.ReadIntBytes(bytes)
540 if err != nil {
541 return nil, err
542 }
543 dst[int(k)] = struct{}{}
544 }
545 *s = dst
546 return bytes, nil
547}
548
549// Msgsize returns the maximum size of the message.
550func (s IntSorted) Msgsize() int {

Callers 4

TestIntSorted_RoundTripFunction · 0.95
TestIntSorted_EmptySetFunction · 0.95

Calls 3

IsNilFunction · 0.92
ReadArrayHeaderBytesFunction · 0.92
ReadIntBytesFunction · 0.92

Tested by 4

TestIntSorted_RoundTripFunction · 0.76
TestIntSorted_EmptySetFunction · 0.76