Skip to content
Permalink
Browse files
Calculate median-of-3 on unsigned values (#242)
  • Loading branch information
peterdettman committed Feb 17, 2022
1 parent af2339a commit 228b9569593f4f8b5e78f54837d484eebbfc248c
Showing 1 changed file with 4 additions and 3 deletions.
@@ -790,7 +790,7 @@ private static void vswap(final int[] fmap, int p1, int p2, int n) {
}
}

private static byte med3(final byte a, final byte b, final byte c) {
private static int med3(final int a, final int b, final int c) {
return (a < b) ? (b < c ? b : a < c ? c : a) : (b > c ? b : a > c ? c
: a);
}
@@ -826,8 +826,9 @@ private void mainQSort3(final BZip2CompressorOutputStream.Data dataShadow,
}
} else {
final int d1 = d + 1;
final int med = med3(block[fmap[lo] + d1],
block[fmap[hi] + d1], block[fmap[(lo + hi) >>> 1] + d1]) & 0xff;
final int med = med3(block[fmap[lo] + d1] & 0xff,
block[fmap[hi] + d1] & 0xff,
block[fmap[(lo + hi) >>> 1] + d1] & 0xff);

int unLo = lo;
int unHi = hi;

0 comments on commit 228b956

Please sign in to comment.