bug 57840: add comments for explicit boxing performance optimization

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1748479 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Javen O'Neal 2016-06-15 01:42:11 +00:00
parent 72ef600ce0
commit 07c65c3fc4
2 changed files with 23 additions and 11 deletions

View File

@ -72,7 +72,8 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
_cells = new TreeMap<Integer, XSSFCell>();
for (CTCell c : row.getCArray()) {
XSSFCell cell = new XSSFCell(this, c);
Integer colI = new Integer(cell.getColumnIndex()); // NOSONAR
// Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer colI = new Integer(cell.getColumnIndex()); // NOSONAR
_cells.put(colI, cell);
sheet.onReadCell(cell);
}
@ -198,6 +199,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
* @see Cell#CELL_TYPE_STRING
*/
public XSSFCell createCell(int columnIndex, int type) {
// Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer colI = new Integer(columnIndex); // NOSONAR
CTCell ctCell;
XSSFCell prev = _cells.get(colI);
@ -238,7 +240,8 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
public XSSFCell getCell(int cellnum, MissingCellPolicy policy) {
if(cellnum < 0) throw new IllegalArgumentException("Cell index must be >= 0");
Integer colI = new Integer(cellnum); // NOSONAR
// Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer colI = new Integer(cellnum); // NOSONAR
XSSFCell cell = _cells.get(colI);
if(policy == RETURN_NULL_AND_BLANK) {
return cell;
@ -458,7 +461,8 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
_sheet.getWorkbook().onDeleteFormula(xcell);
}
Integer colI = new Integer(cell.getColumnIndex()); // NOSONAR
// Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer colI = new Integer(cell.getColumnIndex()); // NOSONAR
_cells.remove(colI);
}

View File

@ -222,7 +222,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
arrayFormulas = new ArrayList<CellRangeAddress>();
for (CTRow row : worksheetParam.getSheetData().getRowArray()) {
XSSFRow r = new XSSFRow(row, this);
Integer rownumI = new Integer(r.getRowNum()); // NOSONAR
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer rownumI = new Integer(r.getRowNum()); // NOSONAR
_rows.put(rownumI, r);
}
}
@ -693,6 +694,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
*/
@Override
public XSSFRow createRow(int rownum) {
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer rownumI = new Integer(rownum); // NOSONAR
CTRow ctRow;
XSSFRow prev = _rows.get(rownumI);
@ -1379,7 +1381,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
*/
@Override
public XSSFRow getRow(int rownum) {
Integer rownumI = new Integer(rownum); // NOSONAR
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer rownumI = new Integer(rownum); // NOSONAR
return _rows.get(rownumI);
}
@ -1409,9 +1412,11 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
}
}
else {
Integer startI = new Integer(startRowNum); // NOSONAR
Integer endI = new Integer(endRowNum+1); // NOSONAR
rows.addAll(_rows.subMap(startI, endI).values());
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer startI = new Integer(startRowNum); // NOSONAR
final Integer endI = new Integer(endRowNum+1); // NOSONAR
final Collection<XSSFRow> inclusive = _rows.subMap(startI, endI).values();
rows.addAll(inclusive);
}
return rows;
}
@ -1881,7 +1886,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
row.removeCell(cell);
}
Integer rownumI = new Integer(row.getRowNum()); // NOSONAR
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer rownumI = new Integer(row.getRowNum()); // NOSONAR
int idx = _rows.headMap(rownumI).size();
_rows.remove(rownumI);
worksheet.getSheetData().removeRow(idx);
@ -2899,7 +2905,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
// check if we should remove this row as it will be overwritten by the data later
if (shouldRemoveRow(startRow, endRow, n, rownum)) {
// remove row from worksheet.getSheetData row array
Integer rownumI = new Integer(row.getRowNum()); // NOSONAR
// Performance optimization: explicit boxing is slightly faster than auto-unboxing, though may use more memory
final Integer rownumI = new Integer(row.getRowNum()); // NOSONAR
int idx = _rows.headMap(rownumI).size();
worksheet.getSheetData().removeRow(idx);
@ -3019,7 +3026,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
//rebuild the _rows map
SortedMap<Integer, XSSFRow> map = new TreeMap<Integer, XSSFRow>();
for(XSSFRow r : _rows.values()) {
Integer rownumI = new Integer(r.getRowNum()); // NOSONAR
// 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;