]> source.dussan.org Git - poi.git/commitdiff
bug 57840: make it easier to replace _rows implementation (HashMap?) by making it...
authorJaven O'Neal <onealj@apache.org>
Wed, 15 Jun 2016 02:56:56 +0000 (02:56 +0000)
committerJaven O'Neal <onealj@apache.org>
Wed, 15 Jun 2016 02:56:56 +0000 (02:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748482 13f79535-47bb-0310-9956-ffa450edef68

src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java

index 13f6b09165e854514cdc3a1e7ba436e59d76c259..5b4013b8aa538f289bef20ee402c280069238fc0 100644 (file)
@@ -110,7 +110,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
     protected CTSheet sheet;
     protected CTWorksheet worksheet;
 
-    private SortedMap<Integer, XSSFRow> _rows;
+    private final SortedMap<Integer, XSSFRow> _rows = new TreeMap<Integer, XSSFRow>();
     private List<XSSFHyperlink> hyperlinks;
     private ColumnHelper columnHelper;
     private CommentsTable sheetComments;
@@ -216,7 +216,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
     }
 
     private void initRows(CTWorksheet worksheetParam) {
-        _rows = new TreeMap<Integer, XSSFRow>();
+        _rows.clear();
         tables = new TreeMap<String, XSSFTable>();
         sharedFormulas = new HashMap<Integer, CTCellFormula>();
         arrayFormulas = new ArrayList<CellRangeAddress>();
@@ -3024,13 +3024,14 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
         rowShifter.updateHyperlinks(shifter);
 
         //rebuild the _rows map
-        SortedMap<Integer, XSSFRow> map = new TreeMap<Integer, XSSFRow>();
+        Map<Integer, XSSFRow> map = new HashMap<Integer, XSSFRow>();
         for(XSSFRow r : _rows.values()) {
             // Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
             final Integer rownumI = new Integer(r.getRowNum()); // NOSONAR
             map.put(rownumI, r);
         }
-        _rows = map;
+        _rows.clear();
+        _rows.putAll(map);
     }
 
     private int shiftedRowNum(int startRow, int endRow, int n, int rownum) {