aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/afp
diff options
context:
space:
mode:
authorAndreas L. Delmelle <adelmelle@apache.org>2009-08-23 19:57:48 +0000
committerAndreas L. Delmelle <adelmelle@apache.org>2009-08-23 19:57:48 +0000
commit6f8f64269426d81124876958b437536536b469f2 (patch)
tree89f9b4e801f6f4b267d367e16b042279924b0ab5 /src/java/org/apache/fop/afp
parent5355a5c8a42aab69db6df7514dd41e4190e81796 (diff)
downloadxmlgraphics-fop-6f8f64269426d81124876958b437536536b469f2.tar.gz
xmlgraphics-fop-6f8f64269426d81124876958b437536536b469f2.zip
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.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@807010 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/afp')
-rw-r--r--src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java b/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java
index 34398b094..e700d76b2 100644
--- a/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java
+++ b/src/java/org/apache/fop/afp/goca/AbstractGraphicsDrawingOrderContainer.java
@@ -46,6 +46,8 @@ implements StructuredData, Completable, Startable {
/** object has started */
private boolean started = false;
+ private int dataLength = 0;
+
/**
* Default constructor
*/
@@ -78,6 +80,7 @@ implements StructuredData, Completable, Startable {
*/
public void addObject(StructuredData object) {
objects.add(object);
+ dataLength += object.getDataLength();
}
/**
@@ -88,6 +91,7 @@ implements StructuredData, Completable, Startable {
public void addAll(AbstractGraphicsDrawingOrderContainer graphicsContainer) {
Collection/*<StructuredDataObject>*/ objects = graphicsContainer.getObjects();
objects.addAll(objects);
+ dataLength += graphicsContainer.getDataLength();
}
/**
@@ -107,9 +111,11 @@ implements StructuredData, Completable, Startable {
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 @@ implements StructuredData, Completable, Startable {
* 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} */