Make BitArray.readUnsignedByte() a bit more clear by using int value instead of byte to prevent unnecessary convert from int to byte.

This commit is contained in:
Lei YU 2015-01-23 23:52:46 +08:00
parent a9b2120fc9
commit 80602b1684

View File

@ -148,16 +148,15 @@ public final class BitArray {
* @return The value of the parsed byte.
*/
public int readUnsignedByte() {
byte b;
int value;
if (bitOffset != 0) {
b = (byte) ((data[byteOffset] << bitOffset)
| ((data[byteOffset + 1] & 0xFF) >> (8 - bitOffset)));
value = (data[byteOffset] << bitOffset)
| ((data[byteOffset + 1] & 0xFF) >>> (8 - bitOffset));
} else {
b = data[byteOffset];
value = data[byteOffset];
}
byteOffset++;
// Converting a signed byte into unsigned.
return b & 0xFF;
return value & 0xFF;
}
/**