Moved BitConstraints#isUnsigned to BitUtils

This commit is contained in:
Collin Smith 2020-08-10 21:22:26 -07:00
parent 90564f39a3
commit 871cadaa2b
2 changed files with 4 additions and 9 deletions

View File

@ -56,11 +56,6 @@ class BitConstraints {
return validateSize(Long.SIZE, bits);
}
public static boolean isUnsigned(long value, int size) {
assert 0 < size && size <= Long.SIZE;
return (value & (1 << (size - 1))) == 0;
}
public static int validateAscii(int bits) {
return _validateSize(Byte.SIZE - 1, Byte.SIZE, bits);
}

View File

@ -304,7 +304,7 @@ public class BitInput {
public byte read7u(int bits) {
BitConstraints.validate7u(bits);
final byte value = (byte) readUnsigned(bits);
assert BitConstraints.isUnsigned(value, Byte.SIZE);
assert BitUtils.isUnsigned(value);
return value;
}
@ -315,7 +315,7 @@ public class BitInput {
public short read15u(int bits) {
BitConstraints.validate15u(bits);
final short value = (short) readUnsigned(bits);
assert BitConstraints.isUnsigned(value, Short.SIZE);
assert BitUtils.isUnsigned(value);
return value;
}
@ -326,7 +326,7 @@ public class BitInput {
public int read31u(int bits) {
BitConstraints.validate31u(bits);
final int value = (int) readUnsigned(bits);
assert BitConstraints.isUnsigned(value, Integer.SIZE);
assert BitUtils.isUnsigned(value);
return value;
}
@ -337,7 +337,7 @@ public class BitInput {
public long read63u(int bits) {
BitConstraints.validate63u(bits);
final long value = (long) readUnsigned(bits);
assert BitConstraints.isUnsigned(value, Long.SIZE);
assert BitUtils.isUnsigned(value);
return value;
}