<changes>
<release version="3.8-beta3" date="2011-??-??">
+ <action dev="poi-developers" type="fix">Tweak the logic for sizing the HSSFCells array on a HSSFRow to reduce memory over allocation in many use cases</action>
<action dev="poi-developers" type="add">49765 - Support for adding a picture to a XSSFRun</action>
<action dev="poi-developers" type="fix">Rename/Move xssf.model.Table to xssf.usermodel.XSSFTable as it now has usermodel-like features</action>
<action dev="poi-developers" type="fix">51061 - Correct target URI for new XSSF Tables</action>
public final static int INITIAL_CAPACITY = 5;
private int rowNum;
- private HSSFCell[] cells=new HSSFCell[INITIAL_CAPACITY];
+ private HSSFCell[] cells;
/**
* reference to low level representation
this.sheet = sheet;
row = record;
setRowNum(record.getRowNumber());
+
+ // Size the initial cell list such that a read only case won't waste
+ // lots of memory, and a create/read followed by adding new cells can
+ // add a bit without needing a resize
+ cells = new HSSFCell[record.getLastCol()+INITIAL_CAPACITY];
+
// Don't trust colIx boundaries as read by other apps
// set the RowRecord empty for the moment
record.setEmpty();
// re-allocate cells array as required.
if(column>=cells.length) {
HSSFCell[] oldCells=cells;
- int newSize=oldCells.length*2;
+ // New size based on the same logic as ArrayList
+ int newSize=oldCells.length*3/2+1;
if(newSize<column+1) {
- newSize=column+1;
+ newSize=column+INITIAL_CAPACITY;
}
cells=new HSSFCell[newSize];
System.arraycopy(oldCells,0,cells,0,oldCells.length);