mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-06 08:18:41 +07:00
Additional assertion to validate invariants
This commit is contained in:
@ -234,6 +234,7 @@ public class BitInput {
|
|||||||
private long readCacheSafe(int bits) {
|
private long readCacheSafe(int bits) {
|
||||||
assert bits > 0 : "bits(" + bits + ") < " + 1;
|
assert bits > 0 : "bits(" + bits + ") < " + 1;
|
||||||
assert bits < Long.SIZE : "bits(" + bits + ") > " + (Long.SIZE - 1);
|
assert bits < Long.SIZE : "bits(" + bits + ") > " + (Long.SIZE - 1);
|
||||||
|
assert bitsCached < bits : "bitsCached(" + bitsCached + ") >= bits(" + bits + ")";
|
||||||
final int bitsToAddCount = bits - bitsCached;
|
final int bitsToAddCount = bits - bitsCached;
|
||||||
final int overflowBits = Byte.SIZE - bitsToAddCount;
|
final int overflowBits = Byte.SIZE - bitsToAddCount;
|
||||||
final long nextByte = byteInput._read8u();
|
final long nextByte = byteInput._read8u();
|
||||||
@ -254,6 +255,7 @@ public class BitInput {
|
|||||||
private long readCacheUnsafe(int bits) {
|
private long readCacheUnsafe(int bits) {
|
||||||
assert bits > 0 : "bits(" + bits + ") < " + 1;
|
assert bits > 0 : "bits(" + bits + ") < " + 1;
|
||||||
assert bits < Long.SIZE : "bits(" + bits + ") > " + (Long.SIZE - 1);
|
assert bits < Long.SIZE : "bits(" + bits + ") > " + (Long.SIZE - 1);
|
||||||
|
assert bitsCached >= bits : "bitsCached(" + bitsCached + ") < bits(" + bits + ")";
|
||||||
final long bitsOut = cache & MASKS[bits];
|
final long bitsOut = cache & MASKS[bits];
|
||||||
cache >>>= bits;
|
cache >>>= bits;
|
||||||
bitsCached -= bits;
|
bitsCached -= bits;
|
||||||
|
Reference in New Issue
Block a user