From 4c82305d3d8394c94249812b02080a115780436a Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Sun, 31 Jan 2016 12:14:55 +0000 Subject: [PATCH] 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 --- src/java/org/apache/poi/hssf/record/EscherAggregate.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/java/org/apache/poi/hssf/record/EscherAggregate.java b/src/java/org/apache/poi/hssf/record/EscherAggregate.java index 21c4db4542..36215b79c3 100644 --- a/src/java/org/apache/poi/hssf/record/EscherAggregate.java +++ b/src/java/org/apache/poi/hssf/record/EscherAggregate.java @@ -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 tailRec = new LinkedHashMap(); + private final Map tailRec = new LinkedHashMap(); /** * 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; -- 2.39.5