Relaxed requirements to allow writing 0 bits (a no-op)

This commit is contained in:
Collin Smith 2020-08-10 18:32:57 -07:00
parent 043e032ec5
commit 4a00f0207f

View File

@ -64,16 +64,17 @@ public class BitOutput {
}
void _writeUnsigned(long value, int bits) {
assert bits > 0 : "bits(" + bits + ") <= " + 0;
assert bits >= 0 : "bits(" + bits + ") < " + 0;
assert bits < Long.SIZE : "bits(" + bits + ") > " + (Long.SIZE - 1);
assert (value & ~MASKS[bits]) == 0 : "value(" + value + ") is larger than bits(" + bits + ")";
_writeRaw(value, bits);
}
void _writeRaw(long value, int bits) {
assert bits > 0 : "bits(" + bits + ") < " + 1;
assert bits >= 0 : "bits(" + bits + ") < " + 0;
assert bits <= Long.SIZE : "bits(" + bits + ") > " + Long.SIZE;
assert bitsCached < Byte.SIZE : "bitsCached(" + bitsCached + ") > " + (Byte.SIZE - 1);
if (bits == 0) return;
incrementBitsWritten(bits);
cache |= (value << bitsCached);
bitsCached += bits;