Pulled unsigned masks out to BitConstants class

This commit is contained in:
Collin Smith 2020-08-08 23:06:36 -07:00
parent c2ce0a3179
commit a9d33c2de8
2 changed files with 13 additions and 6 deletions

View File

@ -0,0 +1,12 @@
package com.riiablo.io;
public class BitConstants {
private BitConstants() {}
static final long[] UNSIGNED_MASKS = new long[Long.SIZE];
static {
for (int i = 1; i < Long.SIZE; i++) {
UNSIGNED_MASKS[i] = (UNSIGNED_MASKS[i - 1] << 1) + 1;
}
}
}

View File

@ -25,12 +25,7 @@ public class BitInput {
private static final int MAX_SAFE_CACHED_BITS = Long.SIZE - Byte.SIZE;
private static final long[] MASKS = new long[Long.SIZE];
static {
for (int i = 1; i < Long.SIZE; i++) {
MASKS[i] = (MASKS[i - 1] << 1) + 1;
}
}
private static final long[] MASKS = BitConstants.UNSIGNED_MASKS;
private final ByteInput byteInput;
private final long numBits;