Author: tilman
Date: Wed Sep  2 15:53:27 2026
New Revision: 1937780

Log:
PDFBOX-5660: refactor to reduce available() calls, as suggested by Valery 
Bokov; closes #517; rename variable for clarity

Modified:
   
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java

Modified: 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
==============================================================================
--- 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
       Wed Sep  2 15:23:10 2026        (r1937779)
+++ 
pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/contentstream/PDFStreamEngine.java
       Wed Sep  2 15:53:27 2026        (r1937780)
@@ -765,13 +765,12 @@ public abstract class PDFStreamEngine
         Matrix textMatrix = state.getTextMatrix();
 
         // read the stream until it is empty
-        InputStream in = new ByteArrayInputStream(string);
-        while (in.available() > 0)
+        InputStream bais = new ByteArrayInputStream(string);
+        for (int before = bais.available(); before > 0; before = 
bais.available())
         {
             // decode a character
-            int before = in.available();
-            int code = font.readCode(in);
-            int codeLength = before - in.available();
+            int code = font.readCode(bais);
+            int codeLength = before - bais.available();
 
             // Word spacing shall be applied to every occurrence of the 
single-byte character code
             // 32 in a string when using a simple font or a composite font 
that defines code 32 as

Reply via email to