RFR JDK-6321472: Add CRC-32C API
David Chase
david.r.chase at oracle.com
Thu Nov 20 19:41:23 UTC 2014
On 2014-11-20, at 7:45 AM, Staffan Friberg <staffan.friberg at oracle.com> wrote:
> Hi,
>
> Anyone who can be the second Reviewer?
>
> Thanks,
> Staffan
I can review, but I am not a Reviewer.
CRC32C.java:
56 /**
57 * CRC-32C Polynom
58 */
“Polynomial”, perhaps?
You did test this on both big- and little-endian boxes, right?
It looks right to me, but this stuff is brain-hurty on mirror-image dyslexia and fenceposts.
It might not hurt to mention that byteTable is for byte-at-a-time calculations and is always
the same, whereas the other 8 tables are for bulk operations and will have contents
dependent on the endianness of the platform.
It would be a good idea to mention that the high-order terms of polynomials
are stored in the low-order bits of the integers in the tables.
You could get the bit reversal out of the init code if you bit-reversed CRC32C_POLY instead and wrote it
78 int r = index;
// High-order polynomial term stored in LSB of r.
79 for (int i = 0; i < Byte.SIZE; i++) {
80 if ((r & 1) != 0) {
81 r = (r >>> 1) ^ REVERSED_CRC32C_POLY;
82 } else {
83 r >>>= 1;
84 }
85 }
86 byteTables[0][index] = r;
at least, it seems that way to me.
David
More information about the core-libs-dev
mailing list