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)
| 1187 | // encoded bytes and the size in bytes of the encoded word array |
| 1188 | // (excluding the terminator byte). |
| 1189 | func getBitArrayWordsLen(b []byte, term byte) (int, int, error) { |
| 1190 | bSearch := b |
| 1191 | numWords := 0 |
| 1192 | sz := 0 |
| 1193 | for { |
| 1194 | if len(bSearch) == 0 { |
| 1195 | return 0, 0, errors.Errorf("slice too short for bit array (%d)", len(b)) |
| 1196 | } |
| 1197 | if bSearch[0] == term { |
| 1198 | break |
| 1199 | } |
| 1200 | vLen, err := getVarintLen(bSearch) |
| 1201 | if err != nil { |
| 1202 | return 0, 0, err |
| 1203 | } |
| 1204 | bSearch = bSearch[vLen:] |
| 1205 | numWords++ |
| 1206 | sz += vLen |
| 1207 | } |
| 1208 | return numWords, sz, nil |
| 1209 | } |
| 1210 | |
| 1211 | // DecodeBitArrayDescending is the descending version of DecodeBitArrayAscending. |
| 1212 | func DecodeBitArrayDescending(b []byte) ([]byte, bitarray.BitArray, error) { |
no test coverage detected
searching dependent graphs…