Skip to content

Commit dc12137

Browse files
committed
Minor final review comments.
1 parent 52549f5 commit dc12137

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/main/java/htsjdk/samtools/cram/compression/rans/Utils.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -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
}

src/main/java/htsjdk/samtools/cram/structure/CompressorCache.java

-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ public ExternalCompressor getCompressorForMethod(
6868
return getCachedCompressorForMethod(compressionMethod, compressorSpecificArg);
6969

7070
case RANS:
71-
// for efficiency, we want to share the same underlying RANS object with both order-0 and
72-
// order-1 ExternalCompressors
7371
final int ransArg = compressorSpecificArg == ExternalCompressor.NO_COMPRESSION_ARG ?
7472
RANS4x8Params.ORDER.ZERO.ordinal() :
7573
compressorSpecificArg;

0 commit comments

Comments
 (0)