pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1737258 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType3.java
Date Thu, 31 Mar 2016 16:56:48 GMT
Author: tilman
Date: Thu Mar 31 16:56:48 2016
New Revision: 1737258

URL: http://svn.apache.org/viewvc?rev=1737258&view=rev
Log:
PDFBOX-3297: optimize function creation

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType3.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType3.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType3.java?rev=1737258&r1=1737257&r2=1737258&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType3.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionType3.java
Thu Mar 31 16:56:48 2016
@@ -30,10 +30,10 @@ import java.io.IOException;
  */
 public class PDFunctionType3 extends PDFunction
 {
-
     private COSArray functions = null;
     private COSArray encode = null;
     private COSArray bounds = null;
+    private PDFunction[] functionsArray = null;
     
     /**
      * Constructor.
@@ -68,13 +68,21 @@ public class PDFunctionType3 extends PDF
         PDRange domain = getDomainForInput(0);
         // clip input value to domain
         x = clipToRange(x, domain.getMin(), domain.getMax());
+        
+        if (functionsArray == null)
+        {
+            COSArray ar = getFunctions();
+            functionsArray = new PDFunction[ar.size()];
+            for (int i = 0; i < ar.size(); ++i)
+            {
+                functionsArray[i] = PDFunction.create(ar.getObject(i));
+            }            
+        }
 
-        COSArray functionsArray = getFunctions();
-        int numberOfFunctions = functionsArray.size();
-        // This doesn't make sense but it may happen ...
-        if (numberOfFunctions == 1) 
+        if (functionsArray.length == 1) 
         {
-            function = PDFunction.create(functionsArray.get(0));
+            // This doesn't make sense but it may happen ...
+            function = functionsArray[0];
             PDRange encRange = getEncodeForParameter(0);
             x = interpolate(x, domain.getMin(), domain.getMax(), encRange.getMin(), encRange.getMax());
         }
@@ -95,7 +103,7 @@ public class PDFunctionType3 extends PDF
                 if ( x >= partitionValues[i] && 
                         (x < partitionValues[i+1] || (i == partitionValuesSize - 2 &&
x == partitionValues[i+1])))
                 {
-                    function = PDFunction.create(functionsArray.get(i));
+                    function = functionsArray[i];
                     PDRange encRange = getEncodeForParameter(i);
                     x = interpolate(x, partitionValues[i], partitionValues[i+1], encRange.getMin(),
encRange.getMax());
                     break;



Mime
View raw message