Skip to content

Commit 5b153a4

Browse files
removing dead code
1 parent c907649 commit 5b153a4

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

sdk/storage/azure-storage-common/src/main/java/com/azure/storage/common/implementation/contentvalidation/StorageCrc64Calculator.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,7 @@ public static long compute(byte[] src, int offset, int length, long uCrc) {
24262426
long uSize = length;
24272427
long uBytes, uStop;
24282428

2429-
uCrc = ~uCrc;
2429+
uCrc = ~uCrc; // Flip all bits of uCrc
24302430

24312431
uStop = uSize - (uSize % 32);
24322432
if (uStop >= 2 * 32) {
@@ -2442,11 +2442,15 @@ public static long compute(byte[] src, int offset, int length, long uCrc) {
24422442
ByteBuffer buffer = ByteBuffer.wrap(src).order(ByteOrder.LITTLE_ENDIAN);
24432443

24442444
for (; pData < pLast; pData += 32) {
2445-
long b0 = buffer.getLong(pData) ^ uCrc0;
2446-
long b1 = buffer.getLong(pData + 8) ^ uCrc1;
2447-
long b2 = buffer.getLong(pData + 16) ^ uCrc2;
2448-
long b3 = buffer.getLong(pData + 24) ^ uCrc3;
2445+
long b0, b1, b2, b3;
24492446

2447+
// Load and XOR data with CRC
2448+
b0 = buffer.getLong(pData) ^ uCrc0;
2449+
b1 = buffer.getLong(pData + 8) ^ uCrc1;
2450+
b2 = buffer.getLong(pData + 16) ^ uCrc2;
2451+
b3 = buffer.getLong(pData + 24) ^ uCrc3;
2452+
2453+
// Unsigned updates using tables and masking
24502454
uCrc0 = M_U32[7 * 256 + ((int) (b0 & 0xFF))];
24512455
b0 >>>= 8;
24522456
uCrc1 = M_U32[7 * 256 + ((int) (b1 & 0xFF))];
@@ -2516,6 +2520,7 @@ public static long compute(byte[] src, int offset, int length, long uCrc) {
25162520
uCrc3 ^= M_U32[((int) (b3 & 0xFF))];
25172521
}
25182522

2523+
// Combine CRC values
25192524
uCrc = 0;
25202525
uCrc ^= ByteBuffer.wrap(src, pData, 8).order(ByteOrder.LITTLE_ENDIAN).getLong() ^ uCrc0;
25212526
uCrc = (uCrc >>> 8) ^ M_U1[(int) (uCrc & 0xFF)];
@@ -2560,11 +2565,12 @@ public static long compute(byte[] src, int offset, int length, long uCrc) {
25602565
pData += 32;
25612566
}
25622567

2568+
// Process remaining bytes
25632569
for (uBytes = 0; uBytes < uSize; ++uBytes, ++pData) {
25642570
uCrc = (uCrc >>> 8) ^ M_U1[(int) ((uCrc ^ src[pData]) & 0xFF)];
25652571
}
25662572

2567-
return ~uCrc;
2573+
return ~uCrc; // Flip all bits of uCrc and return as long
25682574
}
25692575

25702576
/**

0 commit comments

Comments
 (0)