DecodeUvarintDescending decodes a uint64 value which was encoded using EncodeUvarintDescending.
(b []byte)
| 582 | // DecodeUvarintDescending decodes a uint64 value which was encoded |
| 583 | // using EncodeUvarintDescending. |
| 584 | func DecodeUvarintDescending(b []byte) ([]byte, uint64, error) { |
| 585 | if len(b) == 0 { |
| 586 | return nil, 0, errors.Errorf("insufficient bytes to decode uvarint value") |
| 587 | } |
| 588 | length := intZero - int(b[0]) |
| 589 | b = b[1:] // skip length byte |
| 590 | if length < 0 || length > 8 { |
| 591 | return nil, 0, errors.Errorf("invalid uvarint length of %d", length) |
| 592 | } else if len(b) < length { |
| 593 | return nil, 0, errors.Errorf("insufficient bytes to decode uvarint value: %q", b) |
| 594 | } |
| 595 | var x uint64 |
| 596 | for _, t := range b[:length] { |
| 597 | x = (x << 8) | uint64(^t) |
| 598 | } |
| 599 | return b[length:], x, nil |
| 600 | } |
| 601 | |
| 602 | const ( |
| 603 | // <term> -> \x00\x01 |
no test coverage detected
searching dependent graphs…