ASF Bugzilla – Attachment 30953 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]
[patch]
HSSFCellStyle patch (static lock)
poi.sync.short.patch (text/plain), 2.52 KB, created by
Luca Della Toffola
on 2013-10-22 12:56:24 UTC
(
hide
)
Description:
HSSFCellStyle patch (static lock)
Filename:
MIME Type:
Creator:
Luca Della Toffola
Created:
2013-10-22 12:56:24 UTC
Size:
2.52 KB
patch
obsolete
>diff -rupN -x '.*' poi-3.9/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java poi-3.9-patch/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java >--- poi-3.9/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java 2012-11-25 13:27:35.000000000 +0100 >+++ poi-3.9-patch/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java 2013-10-19 19:14:48.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,28 @@ public final class HSSFCellStyle impleme > * @see org.apache.poi.hssf.usermodel.HSSFDataFormat > * @return the format string or "General" if not found > */ >+ >+ private static short lastDateFormat = Short.MIN_VALUE; >+ private static List<FormatRecord> lastFormats = null; >+ private static String getDataFormatStringCache = null; >+ >+ private static final Object cacheLock = new Object(); >+ > public String getDataFormatString() { >- return getDataFormatString(_workbook); >+ synchronized (cacheLock) { >+ if (getDataFormatStringCache != null) { >+ if (lastDateFormat == getDataFormat() && _workbook.getFormats().equals(lastFormats)) { >+ return getDataFormatStringCache; >+ } >+ } >+ >+ lastFormats = _workbook.getFormats(); >+ lastDateFormat = getDataFormat(); >+ >+ getDataFormatStringCache = getDataFormatString(_workbook); >+ >+ return getDataFormatStringCache; >+ } > } > /** > * Get the contents of the format string, by looking up >@@ -828,6 +852,13 @@ public final class HSSFCellStyle impleme > > // Handle matching things if we cross workbooks > if(_workbook != source._workbook) { >+ >+ synchronized (cacheLock) { >+ lastDateFormat = Short.MIN_VALUE; >+ lastFormats = null; >+ getDataFormatStringCache = 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 +905,5 @@ public final class HSSFCellStyle impleme > } > 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 Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 55612
:
30895
| 30953 |
30954