compact similar CHPX after restoring bin table
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1150595 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
aa6a387c8f
commit
e8b148eaef
@ -20,10 +20,12 @@ package org.apache.poi.hwpf.model;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -336,7 +338,35 @@ public class CHPBinTable
|
||||
logger.log( POILogger.DEBUG, "CHPX rebuilded in ",
|
||||
Long.valueOf( System.currentTimeMillis() - start ), " ms (",
|
||||
Integer.valueOf( _textRuns.size() ), " elements)" );
|
||||
}
|
||||
start = System.currentTimeMillis();
|
||||
|
||||
CHPX previous = null;
|
||||
for ( Iterator<CHPX> iterator = _textRuns.iterator(); iterator
|
||||
.hasNext(); )
|
||||
{
|
||||
CHPX current = iterator.next();
|
||||
if ( previous == null )
|
||||
{
|
||||
previous = current;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( previous.getEnd() == current.getStart()
|
||||
&& Arrays
|
||||
.equals( previous.getGrpprl(), current.getGrpprl() ) )
|
||||
{
|
||||
previous.setEnd( current.getEnd() );
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
previous = current;
|
||||
}
|
||||
|
||||
logger.log( POILogger.DEBUG, "CHPX compacted in ",
|
||||
Long.valueOf( System.currentTimeMillis() - start ), " ms (",
|
||||
Integer.valueOf( _textRuns.size() ), " elements)" );
|
||||
}
|
||||
|
||||
private static int binarySearch( List<CHPX> chpxs, int startPosition )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user