Is there a performance difference between these two pieces of code? My gut feeling is that the second option is slower, as the Cell object has to be constructed each time, but I like the idea of returning a Cell.
Option One:
//Call to method
initiTextDefaultCell(borders);
iTextTable.setDefaultCell(iTextDefaultCell);
//Other code...
private void initiTextDefaultCell(boolean borders) {
if (!borders)
iTextDefaultCell.setBorder(Rectangle.NO_BORDER);
else
iTextDefaultCell.setBorder(Rectangle.BOX);
}
Option Two:
//Call to method
iTextTable.setDefaultCell(initiTextDefaultCell(borders));
//Other code...
private Cell initiTextDefaultCell(boolean borders) {
Cell iTextDefaultCell = new Cell();
if (!borders)
iTextDefaultCell.setBorder(Rectangle.NO_BORDER);
else
iTextDefaultCell.setBorder(Rectangle.BOX);
return iTextDefaultCell;
}
Thanks!