readBinaryDeltaSize reads a variable length size from a delta-encoded binary fragment, returing the size and the unused data. Data is encoded as: [[1xxxxxxx]...] [0xxxxxxx] in little-endian order, with 7 bits of the value per byte.
(d []byte)
| 119 | // |
| 120 | // in little-endian order, with 7 bits of the value per byte. |
| 121 | func readBinaryDeltaSize(d []byte) (size int64, rest []byte) { |
| 122 | shift := uint(0) |
| 123 | for i, b := range d { |
| 124 | size |= int64(b&0x7F) << shift |
| 125 | shift += 7 |
| 126 | if b <= 0x7F { |
| 127 | return size, d[i+1:] |
| 128 | } |
| 129 | } |
| 130 | return size, nil |
| 131 | } |
| 132 | |
| 133 | // applyBinaryDeltaAdd applies an add opcode in a delta-encoded binary |
| 134 | // fragment, returning the amount of data written and the usused part of the |
no outgoing calls
no test coverage detected