Skip to content

Commit 7f37a1f

Browse files
committed
refactoring
1 parent aaf744b commit 7f37a1f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

jbbp/src/main/java/com/igormaznitsa/jbbp/io/JBBPBitInputStream.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,9 @@ public class JBBPBitInputStream extends FilterInputStream implements JBBPCountab
4141
protected static final int INITIAL_ARRAY_BUFFER_SIZE =
4242
JBBPSystemProperty.PROPERTY_INPUT_INITIAL_ARRAY_BUFFER_SIZE.getAsInteger(32);
4343
/**
44-
* Flag shows that bit operations must be processed for MSB0 (most significant
45-
* bit 0) mode.
44+
* Contains bit mode for bit operations.
4645
*/
47-
private final boolean msb0;
46+
private final JBBPBitOrder bitOrderMode;
4847
/**
4948
* Internal bit buffer,
5049
*/
@@ -119,7 +118,7 @@ public JBBPBitInputStream(final InputStream in) {
119118
public JBBPBitInputStream(final InputStream in, final JBBPBitOrder order) {
120119
super(in);
121120
this.bitsInBuffer = 0;
122-
this.msb0 = order == JBBPBitOrder.MSB0;
121+
this.bitOrderMode = order;
123122
}
124123

125124
/**
@@ -215,7 +214,7 @@ public int read(final byte[] array, final int offset, final int length) throws I
215214
this.byteCounter += read;
216215
}
217216

218-
if (this.msb0) {
217+
if (this.bitOrderMode == JBBPBitOrder.MSB0) {
219218
int index = offset;
220219
int number = readBytes;
221220
while (number > 0) {
@@ -921,7 +920,7 @@ public int getBufferedBitsNumber() {
921920
*/
922921
@Override
923922
public JBBPBitOrder getBitOrder() {
924-
return this.msb0 ? JBBPBitOrder.MSB0 : JBBPBitOrder.LSB0;
923+
return this.bitOrderMode;
925924
}
926925

927926
/**
@@ -1174,7 +1173,7 @@ public long skip(final long numOfBytes) throws IOException {
11741173
*/
11751174
private int readByteFromStream() throws IOException {
11761175
int result = this.in.read();
1177-
if (result >= 0 && this.msb0) {
1176+
if (result >= 0 && this.bitOrderMode == JBBPBitOrder.MSB0) {
11781177
result = JBBPUtils.reverseBitsInByte((byte) result) & 0xFF;
11791178
}
11801179
return result;

0 commit comments

Comments
 (0)