fix O(n^2) runtime unnecessarily recreating an array inside a for-loop

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1727800 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-01-31 12:14:55 +00:00
parent 6c89d062bf
commit dc860a6f93
1 changed files with 3 additions and 3 deletions

View File

@ -301,7 +301,7 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
/**
* list of "tail" records that need to be serialized after all drawing group records
*/
private Map<Integer, NoteRecord> tailRec = new LinkedHashMap<Integer, NoteRecord>();
private final Map<Integer, NoteRecord> tailRec = new LinkedHashMap<Integer, NoteRecord>();
/**
* create new EscherAggregate
@ -522,8 +522,8 @@ public final class EscherAggregate extends AbstractEscherHolderRecord {
pos += writeDataIntoDrawingRecord(drawingData, writtenEscherBytes, pos, data, i);
}
for (i = 0; i < tailRec.size(); i++) {
Record rec = (Record) tailRec.values().toArray()[i];
for (NoteRecord noteRecord : tailRec.values()) {
Record rec = (Record) noteRecord;
pos += rec.serialize(pos, data);
}
int bytesWritten = pos - offset;