From 6f8f64269426d81124876958b437536536b469f2 Mon Sep 17 00:00:00 2001 From: "Andreas L. Delmelle" Date: Sun, 23 Aug 2009 19:57:48 +0000 Subject: [PATCH] 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 --- ...AbstractGraphicsDrawingOrderContainer.java | 19 ++++++++++--------- status.xml | 4 ++++ 2 files changed, 14 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/**/ 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} */ diff --git a/status.xml b/status.xml index 57ea52204..23269a72b 100644 --- a/status.xml +++ b/status.xml @@ -58,6 +58,10 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> + + Hotspot in AbstractGraphicsDrawingOrderContainer. Reduced time spent in the method + by introducing a member variable to hold the data-length. + White-space handling in markers with inline-content throws a NullPointerException in some cases. -- 2.39.5