aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2014-06-04 15:58:14 +0000
committerNick Burch <nick@apache.org>2014-06-04 15:58:14 +0000
commit4fc7db7cb330107e70dc9c5ca0caf3703e031056 (patch)
treea6db586b1bd582cdb09ab5d7603d414ba67b9f18
parent915ad8c27a51e3876d331af106fff24b01f548a8 (diff)
downloadpoi-4fc7db7cb330107e70dc9c5ca0caf3703e031056.tar.gz
poi-4fc7db7cb330107e70dc9c5ca0caf3703e031056.zip
When finding the CTCol object for a XSSF Sheet column, as we often have to traverse most of the list, and we are mostly reading not changing, switch to fetching all the objects as an array in one go, rather than fetching one at a time, which is hopefully faster. Aims to help bug #56556
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1600319 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
index 767fb6e0b6..41beb6f259 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java
@@ -199,8 +199,15 @@ public class ColumnHelper {
*/
public CTCol getColumn1Based(long index1, boolean splitColumns) {
CTCols colsArray = worksheet.getColsArray(0);
- for (int i = 0; i < colsArray.sizeOfColArray(); i++) {
- CTCol colArray = colsArray.getColArray(i);
+
+ // Fetching the array is quicker than working on the new style
+ // list, assuming we need to read many of them (which we often do),
+ // and assuming we're not making many changes (which we're not)
+ @SuppressWarnings("deprecation")
+ CTCol[] cols = colsArray.getColArray();
+
+ for (int i = 0; i < cols.length; i++) {
+ CTCol colArray = cols[i];
if (colArray.getMin() <= index1 && colArray.getMax() >= index1) {
if (splitColumns) {
if (colArray.getMin() < index1) {