getBitArrayWordsLen returns the number of bit array words in the encoded bytes and the size in bytes of the encoded word array (excluding the terminator byte).
(b []byte, term byte)
| 1671 | // encoded bytes and the size in bytes of the encoded word array |
| 1672 | // (excluding the terminator byte). |
| 1673 | func getBitArrayWordsLen(b []byte, term byte) (int, int, error) { |
| 1674 | bSearch := b |
| 1675 | numWords := 0 |
| 1676 | sz := 0 |
| 1677 | for { |
| 1678 | if len(bSearch) == 0 { |
| 1679 | return 0, 0, errors.Errorf("slice too short for bit array (%d)", len(b)) |
| 1680 | } |
| 1681 | if bSearch[0] == term { |
| 1682 | break |
| 1683 | } |
| 1684 | vLen, err := getVarintLen(bSearch) |
| 1685 | if err != nil { |
| 1686 | return 0, 0, err |
| 1687 | } |
| 1688 | bSearch = bSearch[vLen:] |
| 1689 | numWords++ |
| 1690 | sz += vLen |
| 1691 | } |
| 1692 | return numWords, sz, nil |
| 1693 | } |
| 1694 | |
| 1695 | // DecodeBitArrayDescending is the descending version of DecodeBitArrayAscending. |
| 1696 | func DecodeBitArrayDescending(b []byte) ([]byte, bitarray.BitArray, error) { |
no test coverage detected
searching dependent graphs…