Closed Dekkonot closed 4 years ago
After some testing, I've determined the current method is much faster than the proposed one. Turns out writeByte is fast enough that it doesn't matter and the added overhead of another writeBits is enough to make the function overall much slower.
At the moment, writeUnsigned calls writeByte several times followed by writeBits. It should instead call writeBits with however many bits is needed to make the buffer aligned, call writeByte with whatever is left, then call writeBits after that.
Benchmarks forthcoming, but I assume this will be substantially faster than the current implementation.