mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-31 15:09:21 +07:00
Added bit mask for Long#Size
Reverted previous change writeRaw performs logical-and with bit mask to ensure cache correctness
This commit is contained in:
@ -14,7 +14,7 @@ public class BitConstants {
|
||||
static final int BYTE_SHIFT = Integer.bitCount(Byte.SIZE - 1);
|
||||
static final int BYTE_MASK = (1 << Byte.SIZE) - 1;
|
||||
|
||||
static final long[] UNSIGNED_MASKS = new long[Long.SIZE];
|
||||
static final long[] UNSIGNED_MASKS = new long[Long.SIZE + 1];
|
||||
static {
|
||||
for (int i = 1; i < Long.SIZE; i++) {
|
||||
UNSIGNED_MASKS[i] = (UNSIGNED_MASKS[i - 1] << 1) + 1;
|
||||
|
@ -58,7 +58,7 @@ public class BitOutput {
|
||||
assert bitsCached >= 0 : "bitsCached(" + bitsCached + ") < " + 0;
|
||||
assert bitsCached < Byte.SIZE : "bitsCached(" + bitsCached + ") > " + (Byte.SIZE - 1);
|
||||
if (bitsCached <= 0) return this;
|
||||
byteOutput._write8(cache & MASKS[bitsCached]);
|
||||
byteOutput._write8(cache);
|
||||
clearCache();
|
||||
return this;
|
||||
}
|
||||
@ -101,6 +101,7 @@ public class BitOutput {
|
||||
assert bitsCached < Byte.SIZE : "bitsCached(" + bitsCached + ") > " + (Byte.SIZE - 1);
|
||||
if (bits == 0) return;
|
||||
incrementBitsWritten(bits);
|
||||
value &= MASKS[bits];
|
||||
cache |= (value << bitsCached);
|
||||
bitsCached += bits;
|
||||
|
||||
|
Reference in New Issue
Block a user