You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ad...@apache.org on 2009/08/23 21:57:48 UTC

svn commit: r807010 - in /xmlgraphics/fop/trunk: src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java status.xml

Author: adelmelle
Date: Sun Aug 23 19:57:48 2009
New Revision: 807010

URL: http://svn.apache.org/viewvc?rev=807010&view=rev
Log:
Bugzilla 46883: fixed a hotspot in the AFP renderer. Reduced time spent in the method by introducing a member variable to hold the data-length.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java
    xmlgraphics/fop/trunk/status.xml

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java?rev=807010&r1=807009&r2=807010&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java Sun Aug 23 19:57:48 2009
@@ -46,6 +46,8 @@
     /** object has started */
     private boolean started = false;
 
+    private int dataLength = 0;
+
     /**
      * Default constructor
      */
@@ -78,6 +80,7 @@
      */
     public void addObject(StructuredData object) {
         objects.add(object);
+        dataLength += object.getDataLength();
     }
 
     /**
@@ -88,6 +91,7 @@
     public void addAll(AbstractGraphicsDrawingOrderContainer graphicsContainer) {
         Collection/*<StructuredDataObject>*/ objects = graphicsContainer.getObjects();
         objects.addAll(objects);
+        dataLength += graphicsContainer.getDataLength();
     }
 
     /**
@@ -107,9 +111,11 @@
     public StructuredData removeLast() {
         int lastIndex = objects.size() - 1;
         StructuredData object = null;
-        if (lastIndex > -1) {
-            object = (StructuredData)objects.get(lastIndex);
-            objects.remove(lastIndex);
+        if (lastIndex >= 0) {
+            object = (StructuredData)objects.remove(lastIndex);
+        }
+        if (object != null) {
+            dataLength -= object.getDataLength();
         }
         return object;
     }
@@ -121,12 +127,7 @@
      * all enclosed objects (and their containers)
      */
     public int getDataLength() {
-        int dataLen = 0;
-        Iterator it = objects.iterator();
-        while (it.hasNext()) {
-            dataLen += ((StructuredData)it.next()).getDataLength();
-        }
-        return dataLen;
+        return this.dataLength;
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=807010&r1=807009&r2=807010&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Sun Aug 23 19:57:48 2009
@@ -58,6 +58,10 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Renderers" dev="AD" type="fix" fixes-bug="46883">
+        Hotspot in AbstractGraphicsDrawingOrderContainer. Reduced time spent in the method
+        by introducing a member variable to hold the data-length.
+      </action>
       <action context="Code" dev="AD" type="fix" fixes-bug="47710">
         White-space handling in markers with inline-content throws a NullPointerException
         in some cases.



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org