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 62b9eaed550a9a35d643e0dc85699a9dbc9aceec
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat May 18 08:31:24 2024 -0400

    Refactor common code
---
 .../org/apache/commons/compress/compressors/bzip2/CRC.java | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 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 2f3d17910..2b2e7c1b2 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
@@ -65,18 +65,18 @@ final class CRC {
     }
 
     void update(final int inCh) {
-        int temp = crc >> 24 ^ inCh;
-        if (temp < 0) {
-            temp += 256;
-        }
-        crc = crc << 8 ^ CRC32_TABLE[temp];
+        crc = compute(crc, inCh);
+    }
+
+    private int compute(final int baseCrc, final int inCh) {
+        int index = baseCrc >> 24 ^ inCh;
+        return baseCrc << 8 ^ CRC32_TABLE[index < 0 ? index + 256 : index];
     }
 
     void update(final int inCh, int repeat) {
         int globalCrcShadow = this.crc;
         while (repeat-- > 0) {
-            final int temp = globalCrcShadow >> 24 ^ inCh;
-            globalCrcShadow = globalCrcShadow << 8 ^ CRC32_TABLE[temp < 0 ? 
temp + 256 : temp];
+            globalCrcShadow = compute(globalCrcShadow, inCh);
         }
         this.crc = globalCrcShadow;
     }

Reply via email to