From 061e873f3c4d8d5c23a6ff052328198d49a87b0a Mon Sep 17 00:00:00 2001 From: Sergey Vladimirov Date: Mon, 18 Jul 2011 19:02:16 +0000 Subject: [PATCH] very small additional speed improvement (less garbage) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1148006 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hwpf/model/PAPBinTable.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java index 53b92fcfaa..ea7d52a0be 100644 --- a/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java +++ b/src/scratchpad/src/org/apache/poi/hwpf/model/PAPBinTable.java @@ -48,7 +48,7 @@ public class PAPBinTable { private static final POILogger logger = POILogFactory .getLogger( PAPBinTable.class ); - + protected ArrayList _paragraphs = new ArrayList(); byte[] _dataStream; @@ -64,6 +64,7 @@ public class PAPBinTable * {@link #PAPBinTable(byte[],byte[],byte[],int,int,int,TextPieceTable,boolean)} * instead */ + @SuppressWarnings( "unused" ) public PAPBinTable( byte[] documentStream, byte[] tableStream, byte[] dataStream, int offset, int size, int fcMin, TextPieceTable tpt ) @@ -210,12 +211,21 @@ public class PAPBinTable final Map papxToFileOrder = new IdentityHashMap(); { - int counter = 0; - for ( PAPX papx : _paragraphs ) - { - papxToFileOrder.put( papx, Integer.valueOf( counter++ ) ); - } + int counter = 0; + for ( PAPX papx : _paragraphs ) + { + papxToFileOrder.put( papx, Integer.valueOf( counter++ ) ); + } } + final Comparator papxFileOrderComparator = new Comparator() + { + public int compare( PAPX o1, PAPX o2 ) + { + Integer i1 = papxToFileOrder.get( o1 ); + Integer i2 = papxToFileOrder.get( o2 ); + return i1.compareTo( i2 ); + } + }; logger.log( POILogger.DEBUG, "PAPX's order map created in ", Long.valueOf( System.currentTimeMillis() - start ), " ms" ); @@ -277,15 +287,7 @@ public class PAPBinTable } // restore file order of PAPX - Collections.sort( papxs, new Comparator() - { - public int compare( PAPX o1, PAPX o2 ) - { - Integer i1 = papxToFileOrder.get( o1 ); - Integer i2 = papxToFileOrder.get( o2 ); - return i1.compareTo( i2 ); - } - } ); + Collections.sort( papxs, papxFileOrderComparator ); SprmBuffer sprmBuffer = null; for ( PAPX papx : papxs ) @@ -312,6 +314,10 @@ public class PAPBinTable } this._paragraphs = new ArrayList( newPapxs ); + logger.log( POILogger.DEBUG, "PAPX rebuilded from document text in ", + Long.valueOf( System.currentTimeMillis() - start ), " ms" ); + start = System.currentTimeMillis(); + _dataStream = dataStream; } -- 2.39.5