aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-12-21 22:30:32 +0000
committerPJ Fanning <fanningpj@apache.org>2022-12-21 22:30:32 +0000
commit7807b706acff50de75a92f918150bd080d58e885 (patch)
treec90b1e33228b474c1ba39a760489847988dd9a61 /poi-ooxml
parentf78d742c38b06340ab0733861cacdb5c36bf0dac (diff)
downloadpoi-7807b706acff50de75a92f918150bd080d58e885.tar.gz
poi-7807b706acff50de75a92f918150bd080d58e885.zip
[github-408] Increase performance of StylesTable.putStyle. Thanks to Jason Mirra. This closes #408
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1906152 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java6
1 files changed, 4 insertions, 2 deletions
diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java
index c56cece348..3201544192 100644
--- a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java
+++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/StylesTable.java
@@ -467,10 +467,12 @@ public class StylesTable extends POIXMLDocumentPart implements Styles {
public int putStyle(XSSFCellStyle style) {
CTXf mainXF = style.getCoreXf();
- if(! xfs.contains(mainXF)) {
+ int ret = xfs.indexOf(mainXF);
+ if(ret == -1) {
xfs.add(mainXF);
+ ret = xfs.size() - 1;
}
- return xfs.indexOf(mainXF);
+ return ret;
}
@Override