[PERF] Chunk encoding: simplify writeByte

Rather than append a zero then set the value at that position, append the value.

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
Bryan Boreham 2024-09-18 10:35:29 +01:00
parent b65f1b6560
commit b9a9689aae

View file

@ -95,10 +95,8 @@ func (b *bstream) writeByte(byt byte) {
// Complete the last byte with the leftmost b.count bits from byt.
b.stream[i] |= byt >> (8 - b.count)
b.stream = append(b.stream, 0)
i++
// Write the remainder, if any.
b.stream[i] = byt << b.count
b.stream = append(b.stream, byt<<b.count)
}
// writeBits writes the nbits right-most bits of u to the stream