Author: centic
Date: Tue Dec 31 15:11:59 2013
New Revision: 1554534

URL: http://svn.apache.org/r1554534
Log:
Don't unnecessarily convert from ArrayList to array, use the ArrayList directly 
instead, this speeds up BiffViewer and related unit tests

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/dev/BiffViewer.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/dev/BiffViewer.java
URL: 
http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/dev/BiffViewer.java?rev=1554534&r1=1554533&r2=1554534&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/dev/BiffViewer.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/dev/BiffViewer.java Tue Dec 31 
15:11:59 2013
@@ -88,9 +88,8 @@ public final class BiffViewer {
                                temp.add(record);
 
                                if (dumpInterpretedRecords) {
-                                       String[] headers = 
recListener.getRecentHeaders();
-                                       for (int i = 0; i < headers.length; 
i++) {
-                                               ps.println(headers[i]);
+                                       for (String header : 
recListener.getRecentHeaders()) {
+                                               ps.println(header);
                                        }
                                        ps.print(record.toString());
                                }
@@ -436,7 +435,7 @@ public final class BiffViewer {
 
        private static final class BiffRecordListener implements 
IBiffRecordListener {
                private final Writer _hexDumpWriter;
-               private final List<String> _headers;
+               private List<String> _headers;
                private final boolean _zeroAlignEachRecord;
                private final boolean _noHeader;
                public BiffRecordListener(Writer hexDumpWriter, boolean 
zeroAlignEachRecord, boolean noHeader) {
@@ -462,11 +461,10 @@ public final class BiffViewer {
                                }
                        }
                }
-               public String[] getRecentHeaders() {
-                       String[] result = new String[_headers.size()];
-                       _headers.toArray(result);
-                       _headers.clear();
-                       return result;
+               public List<String> getRecentHeaders() {
+                   List<String> result = _headers;
+                   _headers = new ArrayList<String>();
+                   return result;
                }
                private static String formatRecordDetails(int globalOffset, int 
sid, int size, int recordCounter) {
                        StringBuffer sb = new StringBuffer(64);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@poi.apache.org
For additional commands, e-mail: commits-h...@poi.apache.org

Reply via email to