pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1779822 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
Date Sun, 22 Jan 2017 15:00:50 GMT
Author: lehmi
Date: Sun Jan 22 15:00:50 2017
New Revision: 1779822

URL: http://svn.apache.org/viewvc?rev=1779822&view=rev
Log:
PDFBOX-3627: optimize brute force search as proposed by Marco Monacelli

Modified:
    pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java?rev=1779822&r1=1779821&r2=1779822&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfparser/COSParser.java Sun
Jan 22 15:00:50 2017
@@ -285,7 +285,7 @@ public class COSParser extends BaseParse
                         }
                     }
                 }
-                prev = trailer.getInt(COSName.PREV);
+                prev = trailer.getLong(COSName.PREV);
                 if (prev > 0)
                 {
                     // check the xref table reference
@@ -1190,6 +1190,7 @@ public class COSParser extends BaseParse
             return startXRefOffset;
         }
         source.seek(startXRefOffset);
+        skipSpaces();
         if (source.peek() == X && isString(XREF_TABLE))
         {
             return startXRefOffset;
@@ -1535,7 +1536,7 @@ public class COSParser extends BaseParse
     private long searchNearestValue(List<Long> values, long offset)
     {
         long newValue = -1;
-        long currentDifference = -1;
+        Long currentDifference = null;
         int currentOffsetIndex = -1;
         int numberOfOffsets = values.size();
         // find the nearest value
@@ -1543,7 +1544,7 @@ public class COSParser extends BaseParse
         {
             long newDifference = offset - values.get(i);
             // find the nearest offset
-            if (currentDifference == -1
+            if (currentDifference == null
                     || (Math.abs(currentDifference) > Math.abs(newDifference)))
             {
                 currentDifference = newDifference;



Mime
View raw message