poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1749219 - in /poi/trunk/src: java/org/apache/poi/hssf/usermodel/HSSFSheet.java ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
Date Sun, 19 Jun 2016 22:24:18 GMT
Author: onealj
Date: Sun Jun 19 22:24:17 2016
New Revision: 1749219

URL: http://svn.apache.org/viewvc?rev=1749219&view=rev
Log:
bug 56958: slightly improve performance when checking array formulas

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=1749219&r1=1749218&r2=1749219&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Sun Jun 19 22:24:17 2016
@@ -735,15 +735,17 @@ public final class HSSFSheet implements
     }
 
     private void validateArrayFormulas(CellRangeAddress region) {
+        // FIXME: this may be faster if it looped over array formulas directly rather than
looping over each cell in
+        // the region and searching if that cell belongs to an array formula
         int firstRow = region.getFirstRow();
         int firstColumn = region.getFirstColumn();
         int lastRow = region.getLastRow();
         int lastColumn = region.getLastColumn();
         for (int rowIn = firstRow; rowIn <= lastRow; rowIn++) {
+            HSSFRow row = getRow(rowIn);
+            if (row == null) continue;
+            
             for (int colIn = firstColumn; colIn <= lastColumn; colIn++) {
-                HSSFRow row = getRow(rowIn);
-                if (row == null) continue;
-
                 HSSFCell cell = row.getCell(colIn);
                 if (cell == null) continue;
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java?rev=1749219&r1=1749218&r2=1749219&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java Sun Jun 19 22:24:17
2016
@@ -379,21 +379,23 @@ public class XSSFSheet extends POIXMLDoc
      * @param region
      * @throws IllegalStateException if candidate region intersects an existing array formula
in this sheet
      */
-    private void validateArrayFormulas(CellRangeAddress region){
+    private void validateArrayFormulas(CellRangeAddress region) {
+        // FIXME: this may be faster if it looped over array formulas directly rather than
looping over each cell in
+        // the region and searching if that cell belongs to an array formula
         int firstRow = region.getFirstRow();
         int firstColumn = region.getFirstColumn();
         int lastRow = region.getLastRow();
         int lastColumn = region.getLastColumn();
         // for each cell in sheet, if cell belongs to an array formula, check if merged region
intersects array formula cells
         for (int rowIn = firstRow; rowIn <= lastRow; rowIn++) {
+            XSSFRow row = getRow(rowIn);
+            if (row == null) continue;
+            
             for (int colIn = firstColumn; colIn <= lastColumn; colIn++) {
-                XSSFRow row = getRow(rowIn);
-                if (row == null) continue;
-
                 XSSFCell cell = row.getCell(colIn);
-                if(cell == null) continue;
+                if (cell == null) continue;
 
-                if(cell.isPartOfArrayFormulaGroup()){
+                if (cell.isPartOfArrayFormulaGroup()) {
                     CellRangeAddress arrayRange = cell.getArrayFormulaRange();
                     if (arrayRange.getNumberOfCells() > 1 && region.intersects(arrayRange))
{
                         String msg = "The range " + region.formatAsString() + " intersects
with a multi-cell array formula. " +



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message