poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cedricwal...@apache.org
Subject svn commit: r1583357 - in /poi/trunk/src: java/org/apache/poi/ddf/ java/org/apache/poi/hssf/model/ scratchpad/src/org/apache/poi/hslf/model/ scratchpad/src/org/apache/poi/hwpf/model/
Date Mon, 31 Mar 2014 15:54:52 GMT
Author: cedricwalter
Date: Mon Mar 31 15:54:52 2014
New Revision: 1583357

URL: http://svn.apache.org/r1583357
Log:
performance issue logging calls are expensive because of the objects created when assembling
the log messages. Using the check() method of the logging sub-system can prevent object creation

Modified:
    poi/trunk/src/java/org/apache/poi/ddf/EscherContainerRecord.java
    poi/trunk/src/java/org/apache/poi/ddf/EscherMetafileBlip.java
    poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Xstz.java

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherContainerRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherContainerRecord.java?rev=1583357&r1=1583356&r2=1583357&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherContainerRecord.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherContainerRecord.java Mon Mar 31 15:54:52 2014
@@ -85,7 +85,9 @@ public final class EscherContainerRecord
             addChildRecord(child);
             if (offset >= data.length && bytesRemaining > 0) {
                 _remainingLength = bytesRemaining;
-                log.log(POILogger.WARN, "Not enough Escher data: " + bytesRemaining + " bytes
remaining but no space left");
+                if (log.check(POILogger.WARN)) {
+                    log.log(POILogger.WARN, "Not enough Escher data: " + bytesRemaining +
" bytes remaining but no space left");
+                }
             }
         }
         return bytesWritten;

Modified: poi/trunk/src/java/org/apache/poi/ddf/EscherMetafileBlip.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ddf/EscherMetafileBlip.java?rev=1583357&r1=1583356&r2=1583357&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ddf/EscherMetafileBlip.java (original)
+++ poi/trunk/src/java/org/apache/poi/ddf/EscherMetafileBlip.java Mon Mar 31 15:54:52 2014
@@ -254,31 +254,31 @@ public final class EscherMetafileBlip ex
                 "  Filter: " + HexDump.toHex( field_7_fFilter ) + '\n' +
                 "  Extra Data:" + '\n' + extraData +
                 (remainingData == null ? null : ("\n" +
-                 " Remaining Data: " + HexDump.toHex(remainingData, 32)));
-    }
-
-    @Override
-    public String toXml(String tab) {
-        String extraData = "";
-        StringBuilder builder = new StringBuilder();
-        builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()),
HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
-                .append(tab).append("\t").append("<UID>0x").append(HexDump.toHex( field_1_UID
) + '\n' +
-                                (field_2_UID == null ? "" : ("  UID2: 0x" + HexDump.toHex(
field_2_UID ) + '\n'))).append("</UID>\n")
-                .append(tab).append("\t").append("<UncompressedSize>0x").append(HexDump.toHex(
field_2_cb )).append("</UncompressedSize>\n")
-                .append(tab).append("\t").append("<Bounds>").append(getBounds()).append("</Bounds>\n")
-                .append(tab).append("\t").append("<SizeInEMU>").append(getSizeEMU()).append("</SizeInEMU>\n")
-                .append(tab).append("\t").append("<CompressedSize>0x").append(HexDump.toHex(
field_5_cbSave )).append("</CompressedSize>\n")
-                .append(tab).append("\t").append("<Compression>0x").append(HexDump.toHex(
field_6_fCompression )).append("</Compression>\n")
-                .append(tab).append("\t").append("<Filter>0x").append(HexDump.toHex(
field_7_fFilter )).append("</Filter>\n")
-                .append(tab).append("\t").append("<ExtraData>").append(extraData).append("</ExtraData>\n")
-                .append(tab).append("\t").append("<RemainingData>0x").append(HexDump.toHex(remainingData,
32)).append("</RemainingData>\n");
-        builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
-        return builder.toString();
-    }
-
-    /**
-     * Return the blip signature
-     *
+                 " Remaining Data: " + HexDump.toHex(remainingData, 32)));
+    }
+
+    @Override
+    public String toXml(String tab) {
+        String extraData = "";
+        StringBuilder builder = new StringBuilder();
+        builder.append(tab).append(formatXmlRecordHeader(getClass().getSimpleName(), HexDump.toHex(getRecordId()),
HexDump.toHex(getVersion()), HexDump.toHex(getInstance())))
+                .append(tab).append("\t").append("<UID>0x").append(HexDump.toHex( field_1_UID
) + '\n' +
+                                (field_2_UID == null ? "" : ("  UID2: 0x" + HexDump.toHex(
field_2_UID ) + '\n'))).append("</UID>\n")
+                .append(tab).append("\t").append("<UncompressedSize>0x").append(HexDump.toHex(
field_2_cb )).append("</UncompressedSize>\n")
+                .append(tab).append("\t").append("<Bounds>").append(getBounds()).append("</Bounds>\n")
+                .append(tab).append("\t").append("<SizeInEMU>").append(getSizeEMU()).append("</SizeInEMU>\n")
+                .append(tab).append("\t").append("<CompressedSize>0x").append(HexDump.toHex(
field_5_cbSave )).append("</CompressedSize>\n")
+                .append(tab).append("\t").append("<Compression>0x").append(HexDump.toHex(
field_6_fCompression )).append("</Compression>\n")
+                .append(tab).append("\t").append("<Filter>0x").append(HexDump.toHex(
field_7_fFilter )).append("</Filter>\n")
+                .append(tab).append("\t").append("<ExtraData>").append(extraData).append("</ExtraData>\n")
+                .append(tab).append("\t").append("<RemainingData>0x").append(HexDump.toHex(remainingData,
32)).append("</RemainingData>\n");
+        builder.append(tab).append("</").append(getClass().getSimpleName()).append(">\n");
+        return builder.toString();
+    }
+
+    /**
+     * Return the blip signature
+     *
      * @return the blip signature
      */
     public short getSignature() {
@@ -287,7 +287,9 @@ public final class EscherMetafileBlip ex
             case RECORD_ID_WMF:  return HSSFPictureData.MSOBI_WMF;
             case RECORD_ID_PICT: return HSSFPictureData.MSOBI_PICT;
         }
-        log.log(POILogger.WARN, "Unknown metafile: " + getRecordId());
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Unknown metafile: " + getRecordId());
+        }
         return 0;
     }
 

Modified: poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java?rev=1583357&r1=1583356&r2=1583357&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/model/InternalSheet.java Mon Mar 31 15:54:52 2014
@@ -292,7 +292,9 @@ public final class InternalSheet {
                 // Not clear which application wrote these files.
                 rra = new RowRecordsAggregate();
             } else {
-                log.log(POILogger.WARN, "DIMENSION record not found even though row/cells
present");
+                if (log.check(POILogger.WARN)) {
+                    log.log(POILogger.WARN, "DIMENSION record not found even though row/cells
present");
+                }
                 // Not sure if any tools write files like this, but Excel reads them OK
             }
             dimsloc = findFirstRecordLocBySid(WindowTwoRecord.sid);

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java?rev=1583357&r1=1583356&r2=1583357&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/model/PPGraphics2D.java Mon Mar 31 15:54:52
2014
@@ -359,7 +359,9 @@ public final class PPGraphics2D extends 
      *          this method clears the current <code>Clip</code>.
      */
     public void clip(Shape s){
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
     }
 
     /**
@@ -379,7 +381,9 @@ public final class PPGraphics2D extends 
      * @since       JDK1.1
      */
     public Shape getClip(){
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
         return null;
     }
 
@@ -647,7 +651,9 @@ public final class PPGraphics2D extends 
     public boolean drawImage(Image img, int x, int y,
                              Color bgcolor,
                              ImageObserver observer){
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
 
         return false;
     }
@@ -694,7 +700,9 @@ public final class PPGraphics2D extends 
                              int width, int height,
                              Color bgcolor,
                              ImageObserver observer){
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
 
         return false;
     }
@@ -751,7 +759,9 @@ public final class PPGraphics2D extends 
                              int dx1, int dy1, int dx2, int dy2,
                              int sx1, int sy1, int sx2, int sy2,
                              ImageObserver observer){
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
         return false;
     }
 
@@ -813,7 +823,9 @@ public final class PPGraphics2D extends 
                              int sx1, int sy1, int sx2, int sy2,
                              Color bgcolor,
                              ImageObserver observer){
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
         return false;
     }
 
@@ -851,7 +863,9 @@ public final class PPGraphics2D extends 
      */
     public boolean drawImage(Image img, int x, int y,
                              ImageObserver observer) {
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
         return false;
     }
 
@@ -1036,7 +1050,9 @@ public final class PPGraphics2D extends 
      * @since       JDK1.1
      */
     public void setClip(Shape clip) {
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
     }
 
     /**
@@ -1334,7 +1350,9 @@ public final class PPGraphics2D extends 
      * @see java.awt.AlphaComposite
      */
     public void setComposite(Composite comp){
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
     }
 
     /**
@@ -1345,7 +1363,9 @@ public final class PPGraphics2D extends 
      * @see #setComposite
      */
     public Composite getComposite(){
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
         return null;
     }
 
@@ -1486,7 +1506,9 @@ public final class PPGraphics2D extends 
      * @see #setClip
      */
     public void drawString(AttributedCharacterIterator iterator, float x, float y) {
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
     }
 
     /**
@@ -1589,7 +1611,9 @@ public final class PPGraphics2D extends 
      * @see #setClip(Shape)
      */
      public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
-        log.log(POILogger.WARN, "Not implemented");
+         if (log.check(POILogger.WARN)) {
+             log.log(POILogger.WARN, "Not implemented");
+         }
         return false;
     }
 
@@ -1632,7 +1656,9 @@ public final class PPGraphics2D extends 
     public boolean drawImage(Image img, int x, int y,
                              int width, int height,
                              ImageObserver observer) {
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
         return false;
     }
 
@@ -1679,7 +1705,9 @@ public final class PPGraphics2D extends 
      * @param     c1 the XOR alternation color
      */
     public void setXORMode(Color c1) {
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
     }
 
     /**
@@ -1690,7 +1718,9 @@ public final class PPGraphics2D extends 
      * overwrite the destination with the current color.
      */
     public void setPaintMode() {
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
     }
 
     /**
@@ -1725,7 +1755,9 @@ public final class PPGraphics2D extends 
      * @see #drawRenderedImage
      */
      public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
-        log.log(POILogger.WARN, "Not implemented");
+         if (log.check(POILogger.WARN)) {
+             log.log(POILogger.WARN, "Not implemented");
+         }
     }
 
     /**
@@ -1750,7 +1782,9 @@ public final class PPGraphics2D extends 
      * @see #setClip
      */
     public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
-        log.log(POILogger.WARN, "Not implemented");
+        if (log.check(POILogger.WARN)) {
+            log.log(POILogger.WARN, "Not implemented");
+        }
     }
 
     protected void applyStroke(SimpleShape shape) {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java?rev=1583357&r1=1583356&r2=1583357&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/FIBFieldHandler.java Mon Mar 31
15:54:52 2014
@@ -170,9 +170,11 @@ public final class FIBFieldHandler
         {
           if (dsOffset + dsSize > tableStream.length)
           {
-            log.log(POILogger.WARN, "Unhandled data structure points to outside the buffer.
" +
-                                    "offset = " + dsOffset + ", length = " + dsSize +
-                                    ", buffer length = " + tableStream.length);
+              if (log.check(POILogger.WARN)) {
+                  log.log(POILogger.WARN, "Unhandled data structure points to outside the
buffer. " +
+                          "offset = " + dsOffset + ", length = " + dsSize +
+                          ", buffer length = " + tableStream.length);
+              }
           }
           else
           {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java?rev=1583357&r1=1583356&r2=1583357&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/ListTables.java Mon Mar 31 15:54:52
2014
@@ -143,7 +143,9 @@ public final class ListTables
     	ListLevel lvl = lst.getLevels()[level];
     	return lvl;
     }
-	log.log(POILogger.WARN, "Requested level " + level + " which was greater than the maximum
defined (" + lst.numLevels() + ")");
+    if (log.check(POILogger.WARN)) {
+        log.log(POILogger.WARN, "Requested level " + level + " which was greater than the
maximum defined (" + lst.numLevels() + ")");
+    }
 	return null;
   }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java?rev=1583357&r1=1583356&r2=1583357&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/NilPICFAndBinData.java Mon Mar
31 15:54:52 2014
@@ -42,9 +42,12 @@ public class NilPICFAndBinData
 
         if ( cbHeader != 0x44 )
         {
-            log.log( POILogger.WARN, "NilPICFAndBinData at offset ", offset,
-                    " cbHeader 0x" + Integer.toHexString( cbHeader )
-                            + " != 0x44" );
+            if (log.check(POILogger.WARN)) {
+                log.log(POILogger.WARN, "NilPICFAndBinData at offset ", offset,
+                        " cbHeader 0x" + Integer.toHexString(cbHeader)
+                                + " != 0x44"
+                );
+            }
         }
 
         // skip the 62 ignored bytes

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java?rev=1583357&r1=1583356&r2=1583357&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/PlfLfo.java Mon Mar 31 15:54:52
2014
@@ -106,9 +106,11 @@ public class PlfLfo
 
         if ( ( offset - fcPlfLfo ) != lcbPlfLfo )
         {
-            log.log( POILogger.WARN, "Actual size of PlfLfo is "
-                    + ( offset - fcPlfLfo ) + " bytes, but expected "
-                    + lcbPlfLfo );
+            if (log.check(POILogger.WARN)) {
+                log.log(POILogger.WARN, "Actual size of PlfLfo is "
+                        + (offset - fcPlfLfo) + " bytes, but expected "
+                        + lcbPlfLfo);
+            }
         }
     }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Xstz.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Xstz.java?rev=1583357&r1=1583356&r2=1583357&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Xstz.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwpf/model/Xstz.java Mon Mar 31 15:54:52 2014
@@ -49,8 +49,10 @@ public class Xstz
         short term = LittleEndian.getShort( data, offset );
         if ( term != 0 )
         {
-            log.log( POILogger.WARN, "chTerm at the end of Xstz at offset ",
-                    offset, " is not 0" );
+            if (log.check(POILogger.WARN)) {
+                log.log(POILogger.WARN, "chTerm at the end of Xstz at offset ",
+                        offset, " is not 0");
+            }
         }
     }
 



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


Mime
View raw message