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

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1583357 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Cédric Walter 2014-03-31 15:54:52 +00:00
parent 60801c5017
commit e684262ca6
9 changed files with 108 additions and 57 deletions

View File

@ -85,9 +85,11 @@ public final class EscherContainerRecord extends EscherRecord {
addChildRecord(child);
if (offset >= data.length && bytesRemaining > 0) {
_remainingLength = bytesRemaining;
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not enough Escher data: " + bytesRemaining + " bytes remaining but no space left");
}
}
}
return bytesWritten;
}

View File

@ -287,7 +287,9 @@ public final class EscherMetafileBlip extends EscherBlipRecord {
case RECORD_ID_WMF: return HSSFPictureData.MSOBI_WMF;
case RECORD_ID_PICT: return HSSFPictureData.MSOBI_PICT;
}
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Unknown metafile: " + getRecordId());
}
return 0;
}

View File

@ -292,7 +292,9 @@ public final class InternalSheet {
// Not clear which application wrote these files.
rra = new RowRecordsAggregate();
} else {
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);

View File

@ -359,8 +359,10 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* this method clears the current <code>Clip</code>.
*/
public void clip(Shape s){
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
}
/**
* Gets the current clipping area.
@ -379,7 +381,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @since JDK1.1
*/
public Shape getClip(){
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
return null;
}
@ -647,7 +651,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
public boolean drawImage(Image img, int x, int y,
Color bgcolor,
ImageObserver observer){
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
return false;
}
@ -694,7 +700,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
int width, int height,
Color bgcolor,
ImageObserver observer){
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
return false;
}
@ -751,7 +759,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
int dx1, int dy1, int dx2, int dy2,
int sx1, int sy1, int sx2, int sy2,
ImageObserver observer){
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
return false;
}
@ -813,7 +823,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
int sx1, int sy1, int sx2, int sy2,
Color bgcolor,
ImageObserver observer){
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
return false;
}
@ -851,7 +863,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
*/
public boolean drawImage(Image img, int x, int y,
ImageObserver observer) {
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
return false;
}
@ -1036,8 +1050,10 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @since JDK1.1
*/
public void setClip(Shape clip) {
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
}
/**
* Returns the bounding rectangle of the current clipping area.
@ -1334,8 +1350,10 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see java.awt.AlphaComposite
*/
public void setComposite(Composite comp){
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
}
/**
* Returns the current <code>Composite</code> in the
@ -1345,7 +1363,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setComposite
*/
public Composite getComposite(){
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
return null;
}
@ -1486,8 +1506,10 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setClip
*/
public void drawString(AttributedCharacterIterator iterator, float x, float y) {
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
}
/**
* Checks whether or not the specified <code>Shape</code> intersects
@ -1589,7 +1611,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setClip(Shape)
*/
public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
return false;
}
@ -1632,7 +1656,9 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
public boolean drawImage(Image img, int x, int y,
int width, int height,
ImageObserver observer) {
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
return false;
}
@ -1679,8 +1705,10 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @param c1 the XOR alternation color
*/
public void setXORMode(Color c1) {
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
}
/**
* Sets the paint mode of this graphics context to overwrite the
@ -1690,8 +1718,10 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* overwrite the destination with the current color.
*/
public void setPaintMode() {
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
}
/**
* Renders a
@ -1725,8 +1755,10 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #drawRenderedImage
*/
public void drawRenderedImage(RenderedImage img, AffineTransform xform) {
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
}
/**
* Renders a {@link RenderedImage},
@ -1750,8 +1782,10 @@ public final class PPGraphics2D extends Graphics2D implements Cloneable {
* @see #setClip
*/
public void drawRenderableImage(RenderableImage img, AffineTransform xform) {
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Not implemented");
}
}
protected void applyStroke(SimpleShape shape) {
if (_stroke instanceof BasicStroke){

View File

@ -170,10 +170,12 @@ public final class FIBFieldHandler
{
if (dsOffset + dsSize > 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
{
UnhandledDataStructure unhandled = new UnhandledDataStructure(

View File

@ -143,7 +143,9 @@ public final class ListTables
ListLevel lvl = lst.getLevels()[level];
return lvl;
}
if (log.check(POILogger.WARN)) {
log.log(POILogger.WARN, "Requested level " + level + " which was greater than the maximum defined (" + lst.numLevels() + ")");
}
return null;
}

View File

@ -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

View File

@ -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);
}
}
}

View File

@ -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");
}
}
}