This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit 25dc09b2b18d449b2b75132e0a77c8d2923f7373
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat May 18 08:31:06 2024 -0400

    Refactor constant
---
 .../java/org/apache/commons/compress/compressors/bzip2/CRC.java   | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java 
b/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java
index 2259acb9b..2f3d17910 100644
--- a/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java
+++ b/src/main/java/org/apache/commons/compress/compressors/bzip2/CRC.java
@@ -25,6 +25,8 @@ package org.apache.commons.compress.compressors.bzip2;
  */
 final class CRC {
 
+    private static final int DEFAULT = 0xffffffff;
+
     private static final int[] CRC32_TABLE = { 0x00000000, 0x04c11db7, 
0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, 
0x2608edb8,
             0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 
0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, 0x4593e01e, 0x4152fda9, 
0x5f15adac,
             0x5bd4b01b, 0x569796c2, 0x52568b75, 0x6a1936c8, 0x6ed82b7f, 
0x639b0da6, 0x675a1011, 0x791d4014, 0x7ddc5da3, 0x709f7b7a, 0x745e66cd, 
0x9823b6e0,
@@ -59,13 +61,13 @@ final class CRC {
     }
 
     void reset() {
-        crc = 0xffffffff;
+        crc = DEFAULT;
     }
 
     void update(final int inCh) {
         int temp = crc >> 24 ^ inCh;
         if (temp < 0) {
-            temp = 256 + temp;
+            temp += 256;
         }
         crc = crc << 8 ^ CRC32_TABLE[temp];
     }
@@ -74,7 +76,7 @@ final class CRC {
         int globalCrcShadow = this.crc;
         while (repeat-- > 0) {
             final int temp = globalCrcShadow >> 24 ^ inCh;
-            globalCrcShadow = globalCrcShadow << 8 ^ CRC32_TABLE[temp >= 0 ? 
temp : temp + 256];
+            globalCrcShadow = globalCrcShadow << 8 ^ CRC32_TABLE[temp < 0 ? 
temp + 256 : temp];
         }
         this.crc = globalCrcShadow;
     }

Reply via email to