@@ -24,8 +24,9 @@ public static void reverse(final ByteBuffer byteBuffer) {
2424 reverse (byteBuffer .array (), byteBuffer .arrayOffset (), byteBuffer .limit ());
2525 } else {
2626 for (int i = 0 ; i < byteBuffer .limit (); i ++) {
27+ byte tmp = byteBuffer .get (i );
2728 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 );
2930 }
3031 }
3132 }
@@ -117,12 +118,14 @@ public static void normaliseFrequenciesOrder1(final int[][] F, final int shift)
117118
118119 // log2 N = Math.log(N)/Math.log(2)
119120 int bitSize = (int ) Math .ceil (Math .log (F [Constants .NUMBER_OF_SYMBOLS ][j ]) / Math .log (2 ));
120- if (bitSize > shift )
121+ if (bitSize > shift ) {
121122 bitSize = shift ;
123+ }
122124
123125 // TODO: check if handling bitSize = 0 is required
124- if (bitSize == 0 )
126+ if (bitSize == 0 ) {
125127 bitSize = 1 ; // bitSize cannot be zero
128+ }
126129
127130 // special case -> if a symbol occurs only once and at the end of the input,
128131 // 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
152155 // scale the frequencies to (1 << bits) using the calculated shift
153156 for (int symbol = 0 ; symbol < Constants .NUMBER_OF_SYMBOLS ; symbol ++) {
154157 if (frequencies [symbol ]!=0 ){
155- frequencies [symbol ] <<= shift ;
158+ frequencies [symbol ] <<= shift ;
156159 }
157160 }
158161 }
0 commit comments