Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ default void update(byte[] b, int off, int len) {
* An abstract class implementing {@link ChecksumByteBuffer}
* with a 32-bit checksum and a lookup table.
*/
@SuppressWarnings("innerassignment")
abstract class CrcIntTable implements ChecksumByteBuffer {
/** Current CRC value with bit-flipped. */
private int crc;
Expand Down Expand Up @@ -98,14 +99,21 @@ private static int update(int crc, ByteBuffer b, int[] table) {

// loop unroll - duff's device style
switch (b.remaining()) {
case 7: crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 6: crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 5: crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 4: crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 3: crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 2: crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 1: crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
default: // noop
case 7:
crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 6:
crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 5:
crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 4:
crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 3:
crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 2:
crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
case 1:
crc = (crc >>> 8) ^ table[((crc ^ b.get()) & 0xff)];
default: // noop
}

return crc;
Expand Down