UnmarshalMsg decodes the message from the bytes.
(bytes []byte)
| 519 | |
| 520 | // UnmarshalMsg decodes the message from the bytes. |
| 521 | func (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. |
| 550 | func (s IntSorted) Msgsize() int { |