187
188 /**
189 * Resets CRC-32C to initial value.
190 */
191 @Override
192 public void reset() {
193 crc = 0xFFFFFFFF;
194 }
195
196 /**
197 * Returns CRC-32C value.
198 */
199 @Override
200 public long getValue() {
201 return (~crc) & 0xFFFFFFFFL;
202 }
203
204 /**
205 * Updates the CRC-32C checksum with the specified array of bytes.
206 */
207 private static int updateBytes(int crc, byte[] b, int off, int end) {
208
209 // Do only byte reads for arrays so short they can't be aligned
210 // or if bytes are stored with a larger witdh than one byte.,%
211 if (end - off >= 8 && Unsafe.ARRAY_BYTE_INDEX_SCALE == 1) {
212
213 // align on 8 bytes
214 int alignLength
215 = (8 - ((Unsafe.ARRAY_BYTE_BASE_OFFSET + off) & 0x7)) & 0x7;
216 for (int alignEnd = off + alignLength; off < alignEnd; off++) {
217 crc = (crc >>> 8) ^ byteTable[(crc ^ b[off]) & 0xFF];
218 }
219
220 if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
221 crc = Integer.reverseBytes(crc);
222 }
223
224 // slicing-by-8
225 for (; off < (end - Long.BYTES); off += Long.BYTES) {
226 int firstHalf;
|
187
188 /**
189 * Resets CRC-32C to initial value.
190 */
191 @Override
192 public void reset() {
193 crc = 0xFFFFFFFF;
194 }
195
196 /**
197 * Returns CRC-32C value.
198 */
199 @Override
200 public long getValue() {
201 return (~crc) & 0xFFFFFFFFL;
202 }
203
204 /**
205 * Updates the CRC-32C checksum with the specified array of bytes.
206 */
207 @SuppressWarnings("deprecation") // Unsafe.{getInt, getLong}
208 private static int updateBytes(int crc, byte[] b, int off, int end) {
209
210 // Do only byte reads for arrays so short they can't be aligned
211 // or if bytes are stored with a larger witdh than one byte.,%
212 if (end - off >= 8 && Unsafe.ARRAY_BYTE_INDEX_SCALE == 1) {
213
214 // align on 8 bytes
215 int alignLength
216 = (8 - ((Unsafe.ARRAY_BYTE_BASE_OFFSET + off) & 0x7)) & 0x7;
217 for (int alignEnd = off + alignLength; off < alignEnd; off++) {
218 crc = (crc >>> 8) ^ byteTable[(crc ^ b[off]) & 0xFF];
219 }
220
221 if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN) {
222 crc = Integer.reverseBytes(crc);
223 }
224
225 // slicing-by-8
226 for (; off < (end - Long.BYTES); off += Long.BYTES) {
227 int firstHalf;
|