ASF Bugzilla – Attachment 30895 Details for
Bug 55612
Performance improvement (~11% up to ~92%) by adding a cache to HSSFCellStyle.getDataFormatString()
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
HSSFCellStyle patch
HSSFCellStyle.patch (text/plain), 2.48 KB, created by
Luca Della Toffola
on 2013-09-30 09:34:59 UTC
(
hide
)
Description:
HSSFCellStyle patch
Filename:
MIME Type:
Creator:
Luca Della Toffola
Created:
2013-09-30 09:34:59 UTC
Size:
2.48 KB
patch
obsolete
>--- HSSFCellStyle.java 2012-11-25 13:27:35.000000000 +0100 >+++ HSSFCellStyleFix.java 2013-09-25 15:34:26.000000000 +0200 >@@ -18,9 +18,13 @@ > > package org.apache.poi.hssf.usermodel; > >+import java.util.Arrays; >+import java.util.List; >+ > import org.apache.poi.hssf.model.InternalWorkbook; > import org.apache.poi.hssf.record.ExtendedFormatRecord; > import org.apache.poi.hssf.record.FontRecord; >+import org.apache.poi.hssf.record.FormatRecord; > import org.apache.poi.hssf.record.StyleRecord; > import org.apache.poi.hssf.util.HSSFColor; > import org.apache.poi.ss.usermodel.CellStyle; >@@ -106,8 +110,29 @@ > * @see org.apache.poi.hssf.usermodel.HSSFDataFormat > * @return the format string or "General" if not found > */ >+ private static ExtendedFormatRecord lastFormat = null; >+ private static int[] lastFormatSummary = null; >+ private static short lastIndex = -1; >+ private static List<FormatRecord> lastFormats = null; >+ private static String cache = null; >+ > public String getDataFormatString() { >- return getDataFormatString(_workbook); >+ if (cache != null && _format == null && lastFormat == null && lastIndex == _index && _workbook.getFormats() == lastFormats && _workbook.getFormats().equals(lastFormats)) { >+ return cache; >+ } else if (cache != null && _format != null && lastFormat != null && lastIndex == _index && _workbook.getFormats() == lastFormats && _workbook.getFormats().equals(lastFormats) && Arrays.equals(lastFormatSummary, _format.stateSummary())) { >+ return cache; >+ } else { >+ // cache miss: >+ // 1) compute result >+ cache = getDataFormatString(_workbook); >+ // 2) store state of 'this' for the next time >+ lastFormat = _format; >+ lastFormats = _workbook.getFormats(); >+ if (_format != null) lastFormatSummary = _format.stateSummary(); >+ else lastFormatSummary = null; >+ lastIndex = _index; >+ return cache; >+ } > } > /** > * Get the contents of the format string, by looking up >@@ -828,6 +853,13 @@ > > // Handle matching things if we cross workbooks > if(_workbook != source._workbook) { >+ >+ cache = null; >+ lastFormat = null; >+ lastFormatSummary = null; >+ lastIndex = -1; >+ lastFormats = null; >+ > // Then we need to clone the format string, > // and update the format record for this > short fmt = (short)_workbook.createFormat(source.getDataFormatString() ); >@@ -874,4 +906,5 @@ > } > return false; > } >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 55612
: 30895 |
30953
|
30954