@@ -24,8 +24,9 @@ public static void reverse(final ByteBuffer byteBuffer) {
24
24
reverse (byteBuffer .array (), byteBuffer .arrayOffset (), byteBuffer .limit ());
25
25
} else {
26
26
for (int i = 0 ; i < byteBuffer .limit (); i ++) {
27
+ byte tmp = byteBuffer .get (i );
27
28
byteBuffer .put (i , byteBuffer .get (byteBuffer .limit () - i - 1 ));
28
- byteBuffer .put (byteBuffer .limit () - i - 1 , byteBuffer . get ( i ) );
29
+ byteBuffer .put (byteBuffer .limit () - i - 1 , tmp );
29
30
}
30
31
}
31
32
}
@@ -117,12 +118,14 @@ public static void normaliseFrequenciesOrder1(final int[][] F, final int shift)
117
118
118
119
// log2 N = Math.log(N)/Math.log(2)
119
120
int bitSize = (int ) Math .ceil (Math .log (F [Constants .NUMBER_OF_SYMBOLS ][j ]) / Math .log (2 ));
120
- if (bitSize > shift )
121
+ if (bitSize > shift ) {
121
122
bitSize = shift ;
123
+ }
122
124
123
125
// TODO: check if handling bitSize = 0 is required
124
- if (bitSize == 0 )
126
+ if (bitSize == 0 ) {
125
127
bitSize = 1 ; // bitSize cannot be zero
128
+ }
126
129
127
130
// special case -> if a symbol occurs only once and at the end of the input,
128
131
// then the order 0 freq table associated with it should have a frequency of 1 for symbol 0
@@ -152,7 +155,7 @@ public static void normaliseFrequenciesOrder0Shift(final int[] frequencies, fina
152
155
// scale the frequencies to (1 << bits) using the calculated shift
153
156
for (int symbol = 0 ; symbol < Constants .NUMBER_OF_SYMBOLS ; symbol ++) {
154
157
if (frequencies [symbol ]!=0 ){
155
- frequencies [symbol ] <<= shift ;
158
+ frequencies [symbol ] <<= shift ;
156
159
}
157
160
}
158
161
}
0 commit comments