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

Method UnmarshalMsg

msgp/setof/generated.go:365–391  ·  view source on GitHub ↗

UnmarshalMsg decodes the message from the bytes.

(bytes []byte)

Source from the content-addressed store, hash-verified

363
364// UnmarshalMsg decodes the message from the bytes.
365func (s *Int) UnmarshalMsg(bytes []byte) ([]byte, error) {
366 if msgp.IsNil(bytes) {
367 *s = nil
368 return bytes[msgp.NilSize:], nil
369 }
370 // Read the array header
371 sz, bytes, err := msgp.ReadArrayHeaderBytes(bytes)
372 if err != nil {
373 return nil, err
374 }
375 dst := *s
376 if dst == nil {
377 dst = make(Int, sz)
378 } else {
379 clear(dst)
380 }
381 for range sz {
382 var k int
383 k, bytes, err = msgp.ReadIntBytes(bytes)
384 if err != nil {
385 return nil, err
386 }
387 dst[int(k)] = struct{}{}
388 }
389 *s = dst
390 return bytes, nil
391}
392
393// Msgsize returns the maximum size of the message.
394func (s Int) Msgsize() int {

Callers 4

TestInt_RoundTripFunction · 0.95
TestInt_NilHandlingFunction · 0.95
TestInt_EmptySetFunction · 0.95

Calls 3

IsNilFunction · 0.92
ReadArrayHeaderBytesFunction · 0.92
ReadIntBytesFunction · 0.92

Tested by 4

TestInt_RoundTripFunction · 0.76
TestInt_NilHandlingFunction · 0.76
TestInt_EmptySetFunction · 0.76