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

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pdfbox-jbig2.git


The following commit(s) were added to refs/heads/master by this push:
     new 3fa1579  PDFBOX-5660: use loop, adjust final
3fa1579 is described below

commit 3fa1579d4f0ab73a93d939fde856e6967f226521
Author: Tilman Hausherr <[email protected]>
AuthorDate: Wed May 13 13:38:08 2026 +0200

    PDFBOX-5660: use loop, adjust final
---
 .../org/apache/pdfbox/jbig2/SegmentHeader.java     |  3 +--
 .../jbig2/decoder/huffman/StandardTables.java      | 14 ++++++-----
 .../pdfbox/jbig2/decoder/mmr/MMRDecompressor.java  | 27 +++++++++++-----------
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/src/main/java/org/apache/pdfbox/jbig2/SegmentHeader.java 
b/src/main/java/org/apache/pdfbox/jbig2/SegmentHeader.java
index 558f93a..77b045f 100644
--- a/src/main/java/org/apache/pdfbox/jbig2/SegmentHeader.java
+++ b/src/main/java/org/apache/pdfbox/jbig2/SegmentHeader.java
@@ -56,9 +56,8 @@ public class SegmentHeader
                 { 43, GenericRefinementRegion.class }, { 48, 
PageInformation.class },
                 { 50, EndOfStripe.class }, { 52, Profiles.class }, { 53, 
Table.class }, };
 
-        for (int i = 0; i < SEGMENT_TYPES.length; i++)
+        for (Object[] objects : SEGMENT_TYPES)
         {
-            Object[] objects = SEGMENT_TYPES[i];
             SEGMENT_TYPE_MAP.put((Integer) objects[0], (Class<? extends 
SegmentData>) objects[1]);
         }
     }
diff --git 
a/src/main/java/org/apache/pdfbox/jbig2/decoder/huffman/StandardTables.java 
b/src/main/java/org/apache/pdfbox/jbig2/decoder/huffman/StandardTables.java
index 1f51a50..29d6694 100644
--- a/src/main/java/org/apache/pdfbox/jbig2/decoder/huffman/StandardTables.java
+++ b/src/main/java/org/apache/pdfbox/jbig2/decoder/huffman/StandardTables.java
@@ -29,14 +29,16 @@ public class StandardTables
 
             List<Code> codeTable = new ArrayList<Code>();
 
-            for (int i = 0; i < table.length; i++)
+            for (int[] subTable : table)
             {
-                int prefixLength = table[i][0];
-                int rangeLength = table[i][1];
-                int rangeLow = table[i][2];
+                int prefixLength = subTable[0];
+                int rangeLength = subTable[1];
+                int rangeLow = subTable[2];
                 boolean isLowerRange = false;
-                if (table[i].length > 3)
+                if (subTable.length > 3)
+                {
                     isLowerRange = true;
+                }
                 codeTable.add(new Code(prefixLength, rangeLength, rangeLow, 
isLowerRange));
             }
 
@@ -261,7 +263,7 @@ public class StandardTables
                     { 7, 32, 25 } /* high */
             } };
 
-    private static HuffmanTable STANDARD_TABLES[] = new 
HuffmanTable[TABLES.length];
+    private static final HuffmanTable STANDARD_TABLES[] = new 
HuffmanTable[TABLES.length];
 
     public static HuffmanTable getTable(int number)
     {
diff --git 
a/src/main/java/org/apache/pdfbox/jbig2/decoder/mmr/MMRDecompressor.java 
b/src/main/java/org/apache/pdfbox/jbig2/decoder/mmr/MMRDecompressor.java
index b730763..56ab747 100644
--- a/src/main/java/org/apache/pdfbox/jbig2/decoder/mmr/MMRDecompressor.java
+++ b/src/main/java/org/apache/pdfbox/jbig2/decoder/mmr/MMRDecompressor.java
@@ -31,8 +31,8 @@ import org.apache.pdfbox.jbig2.Bitmap;
 public class MMRDecompressor
 {
 
-    private int width;
-    private int height;
+    private final int width;
+    private final int height;
 
     /**
      * A class encapsulating the compressed raw data.
@@ -76,12 +76,12 @@ public class MMRDecompressor
             }
         }
 
-        private final Code uncompressGetCode(Code table[])
+        private Code uncompressGetCode(Code table[])
         {
             return uncompressGetCodeLittleEndian(table);
         }
 
-        private final Code uncompressGetCodeLittleEndian(Code table[])
+        private Code uncompressGetCodeLittleEndian(Code table[])
         {
             final int code = uncompressGetNextCodeLittleEndian() & 0xffffff;
             Code result = table[code >> CODE_OFFSET - FIRST_LEVEL_TABLE_SIZE];
@@ -102,7 +102,7 @@ public class MMRDecompressor
          * This method returns code words of 16 bits, which are aligned to the 
24th bit. The lowest 8 bits are used as a
          * "queue" of bits so that an access to the actual data is only 
needed, when this queue becomes empty.
          */
-        private final int uncompressGetNextCodeLittleEndian()
+        private int uncompressGetNextCodeLittleEndian()
         {
             try
             {
@@ -199,7 +199,7 @@ public class MMRDecompressor
                     // CK: if filling degree is too small,
                     // smoothly fill up to the next three bytes or substitute 
with with
                     // empty bytes
-                    int read = 0;
+                    int read;
                     while (bufferTop < 3)
                     {
                         try
@@ -275,9 +275,9 @@ public class MMRDecompressor
     private static Code blackTable[] = null;
     private static Code modeTable[] = null;
 
-    private RunData data;
+    private final RunData data;
 
-    private synchronized final static void initTables()
+    private static synchronized void initTables()
     {
         if (null == whiteTable)
         {
@@ -287,7 +287,7 @@ public class MMRDecompressor
         }
     }
 
-    private final int uncompress2D(RunData runData, int[] referenceOffsets, 
int refRunLength,
+    private int uncompress2D(RunData runData, int[] referenceOffsets, int 
refRunLength,
             int[] runOffsets, int width)
     {
 
@@ -516,7 +516,7 @@ public class MMRDecompressor
         referenceOffsets[0] = width;
         int refRunLength = 1;
 
-        int count = 0;
+        int count;
 
         for (int line = 0; line < height; line++)
         {
@@ -601,7 +601,7 @@ public class MMRDecompressor
         }
     }
 
-    private final int uncompress1D(RunData runData, int[] runOffsets, int 
width)
+    private int uncompress1D(RunData runData, int[] runOffsets, int width)
     {
 
         boolean whiteRun = true;
@@ -670,10 +670,9 @@ public class MMRDecompressor
     private static Code[] createLittleEndianTable(int codes[][])
     {
         final Code firstLevelTable[] = new Code[FIRST_LEVEL_TABLE_MASK + 1];
-        for (int i = 0; i < codes.length; i++)
+        for (int[] cod : codes)
         {
-            final Code code = new Code(codes[i]);
-
+            final Code code = new Code(cod);
             if (code.bitLength <= FIRST_LEVEL_TABLE_SIZE)
             {
                 final int variantLength = FIRST_LEVEL_TABLE_SIZE - 
code.bitLength;

Reply via email to