]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla #52206: small performance improvements by declaring some class members as...
authorVincent Hennebert <vhennebert@apache.org>
Mon, 5 Dec 2011 14:38:34 +0000 (14:38 +0000)
committerVincent Hennebert <vhennebert@apache.org>
Mon, 5 Dec 2011 14:38:34 +0000 (14:38 +0000)
Patch by Alexis Giotis, applied with minor modifications

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1210477 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/ElementMappingRegistry.java
src/java/org/apache/fop/fo/FOTreeBuilder.java
src/java/org/apache/fop/fo/FObj.java
src/java/org/apache/fop/fo/properties/PropertyMaker.java

index cf14fa281f85bef9c4bce73ce45d8f9e59b33048..b6baeca2b96f8449b4b74f3ff041dfdc3779aeed 100644 (file)
@@ -23,7 +23,6 @@ import java.util.Iterator;
 import java.util.Map;
 
 import org.w3c.dom.DOMImplementation;
-
 import org.xml.sax.Locator;
 
 import org.apache.commons.logging.Log;
@@ -42,7 +41,7 @@ import org.apache.fop.fo.ElementMapping.Maker;
 public class ElementMappingRegistry {
 
     /** logging instance */
-    protected Log log = LogFactory.getLog(ElementMappingRegistry.class);
+    private static final Log LOG = LogFactory.getLog(ElementMappingRegistry.class);
 
     /**
      * Table mapping element names to the makers of objects
@@ -79,7 +78,7 @@ public class ElementMappingRegistry {
                 try {
                     addElementMapping(mapping);
                 } catch (IllegalArgumentException e) {
-                    log.warn("Error while adding element mapping", e);
+                    LOG.warn("Error while adding element mapping", e);
                 }
 
             }
index 451481eb8e57377617ed25c42f7a629bf0889e8d..629e87e6b924b9f7fefbb93ef0f61747a6427629 100644 (file)
@@ -53,7 +53,7 @@ import org.apache.fop.util.ContentHandlerFactory.ObjectSource;
 public class FOTreeBuilder extends DefaultHandler {
 
     /** logging instance */
-    protected Log log = LogFactory.getLog(FOTreeBuilder.class);
+    private static final Log LOG = LogFactory.getLog(FOTreeBuilder.class);
 
     /** The registry for ElementMapping instances */
     protected ElementMappingRegistry elementMappingRegistry;
@@ -140,8 +140,8 @@ public class FOTreeBuilder extends DefaultHandler {
         used = true;
         empty = true;
         rootFObj = null;    // allows FOTreeBuilder to be reused
-        if (log.isDebugEnabled()) {
-            log.debug("Building formatting object tree");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Building formatting object tree");
         }
         foEventHandler.startDocument();
         this.mainFOHandler = new MainFOHandler();
@@ -158,8 +158,8 @@ public class FOTreeBuilder extends DefaultHandler {
             eventProducer.emptyDocument(this);
         }
         rootFObj = null;
-        if (log.isDebugEnabled()) {
-            log.debug("Parsing of document complete");
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Parsing of document complete");
         }
         foEventHandler.endDocument();
     }
@@ -188,17 +188,17 @@ public class FOTreeBuilder extends DefaultHandler {
 
     /** {@inheritDoc} */
     public void warning(SAXParseException e) {
-        log.warn(e.getLocalizedMessage());
+        LOG.warn(e.getLocalizedMessage());
     }
 
     /** {@inheritDoc} */
     public void error(SAXParseException e) {
-        log.error(e.toString());
+        LOG.error(e.toString());
     }
 
     /** {@inheritDoc} */
     public void fatalError(SAXParseException e) throws SAXException {
-        log.error(e.toString());
+        LOG.error(e.toString());
         throw e;
     }
 
@@ -364,7 +364,7 @@ public class FOTreeBuilder extends DefaultHandler {
             }
 
             if (currentFObj.getParent() == null) {
-                log.debug("endElement for top-level " + currentFObj.getName());
+                LOG.debug("endElement for top-level " + currentFObj.getName());
             }
 
             currentFObj = currentFObj.getParent();
index 98661b8b6e4f366f959fbead10051a540e2a7d1f..27d0711f2cd661d09b7e7b7cffcd6ad5a51d8727 100644 (file)
@@ -627,7 +627,7 @@ public abstract class FObj extends FONode implements Constants {
     }
 
     /** Basic {@link FONode.FONodeIterator} implementation */
-    public class FObjIterator implements FONodeIterator {
+    public static class FObjIterator implements FONodeIterator {
 
         private static final int F_NONE_ALLOWED = 0;
         private static final int F_SET_ALLOWED = 1;
index ba17b1850af0cc78d921a9a7571c56b218560603..795db56e750966d200257a4aa13815b7dd7d0994 100644 (file)
@@ -43,7 +43,9 @@ import org.apache.fop.fo.expr.PropertyParser;
 public class PropertyMaker implements Cloneable {
 
     /** Logger instance */
-    private static Log log = LogFactory.getLog(PropertyMaker.class);
+    private static final Log LOG = LogFactory.getLog(PropertyMaker.class);
+
+    private static final boolean IS_LOG_TRACE_ENABLED = LOG.isTraceEnabled();
 
     /** the property ID */
     protected int propId;
@@ -250,8 +252,8 @@ public class PropertyMaker implements Cloneable {
                 throws PropertyException {
         Property p = null;
 
-        if (log.isTraceEnabled()) {
-            log.trace("PropertyMaker.findProperty: "
+        if (IS_LOG_TRACE_ENABLED) {
+            LOG.trace("PropertyMaker.findProperty: "
                   + FOPropertyMapping.getPropertyName(propId)
                   + ", " + propertyList.getFObj().getName());
         }
@@ -377,14 +379,14 @@ public class PropertyMaker implements Cloneable {
      */
     public Property make(PropertyList propertyList) throws PropertyException {
         if (defaultProperty != null) {
-            if (log.isTraceEnabled()) {
-                log.trace("PropertyMaker.make: reusing defaultProperty, "
+            if (IS_LOG_TRACE_ENABLED) {
+                LOG.trace("PropertyMaker.make: reusing defaultProperty, "
                       + FOPropertyMapping.getPropertyName(propId));
             }
             return defaultProperty;
         }
-        if (log.isTraceEnabled()) {
-            log.trace("PropertyMaker.make: making default property value, "
+        if (IS_LOG_TRACE_ENABLED) {
+            LOG.trace("PropertyMaker.make: making default property value, "
                   + FOPropertyMapping.getPropertyName(propId)
                   + ", " + propertyList.getFObj().getName());
         }
@@ -413,7 +415,7 @@ public class PropertyMaker implements Cloneable {
                 if ((propId & Constants.COMPOUND_MASK) != 0) {
                     newProp = getSubprop(newProp, propId & Constants.COMPOUND_MASK);
                 }
-                if (!isInherited() && log.isWarnEnabled()) {
+                if (!isInherited() && LOG.isWarnEnabled()) {
                     /* check whether explicit value is available on the parent
                      * (for inherited properties, an inherited value will always
                      *  be available)
@@ -421,7 +423,7 @@ public class PropertyMaker implements Cloneable {
                     Property parentExplicit = propertyList.getParentPropertyList()
                                                 .getExplicit(getPropId());
                     if (parentExplicit == null) {
-                        log.warn(FOPropertyMapping.getPropertyName(getPropId())
+                        LOG.warn(FOPropertyMapping.getPropertyName(getPropId())
                                 + "=\"inherit\" on " + propertyList.getFObj().getName()
                                 + ", but no explicit value found on the parent FO.");
                     }