poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1751131 - in /poi/trunk/src: java/org/apache/poi/ss/formula/functions/ java/org/apache/poi/ss/formula/ptg/ java/org/apache/poi/ss/usermodel/ java/org/apache/poi/ss/util/ java/org/apache/poi/util/ ooxml/java/org/apache/poi/poifs/crypt/dsig/...
Date Sun, 03 Jul 2016 07:20:47 GMT
Author: onealj
Date: Sun Jul  3 07:20:47 2016
New Revision: 1751131

URL: http://svn.apache.org/viewvc?rev=1751131&view=rev
Log:
bug 59773: move loop invariants outside of loop or change for loops to for-each loops

Modified:
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/CountUtils.java
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/DStarRunner.java
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/Mode.java
    poi/trunk/src/java/org/apache/poi/ss/formula/functions/TextFunction.java
    poi/trunk/src/java/org/apache/poi/ss/formula/ptg/ArrayPtg.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
    poi/trunk/src/java/org/apache/poi/ss/usermodel/DateUtil.java
    poi/trunk/src/java/org/apache/poi/ss/util/AreaReference.java
    poi/trunk/src/java/org/apache/poi/util/DrawingDump.java
    poi/trunk/src/java/org/apache/poi/util/StringUtil.java
    poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFEvaluationWorkbook.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/BooleanFunction.java Sun Jul  3
07:20:47 2016
@@ -60,9 +60,8 @@ public abstract class BooleanFunction im
 		/*
 		 * Note: no short-circuit boolean loop exit because any ErrorEvals will override the result
 		 */
-		for (int i=0, iSize=args.length; i<iSize; i++) {
+		for (final ValueEval arg : args) {
             Boolean tempVe;
-			ValueEval arg = args[i];
 			if (arg instanceof TwoDEval) {
 				TwoDEval ae = (TwoDEval) arg;
 				int height = ae.getHeight();
@@ -81,7 +80,9 @@ public abstract class BooleanFunction im
 			}
             if (arg instanceof RefEval) {
                 RefEval re = (RefEval) arg;
-                for (int sIx = re.getFirstSheetIndex(); sIx <= re.getLastSheetIndex();
sIx++) {
+                final int firstSheetIndex = re.getFirstSheetIndex();
+                final int lastSheetIndex = re.getLastSheetIndex();
+                for (int sIx = firstSheetIndex; sIx <= lastSheetIndex; sIx++) {
                     ValueEval ve = re.getInnerValueEval(sIx);
                     tempVe = OperandResolver.coerceValueToBoolean(ve, true);
                     if (tempVe != null) {

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/CountUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/CountUtils.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/CountUtils.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/CountUtils.java Sun Jul  3 07:20:47
2016
@@ -49,7 +49,9 @@ final class CountUtils {
     public static int countMatchingCellsInArea(ThreeDEval areaEval, I_MatchPredicate criteriaPredicate)
{
         int result = 0;
 
-        for (int sIx=areaEval.getFirstSheetIndex(); sIx <= areaEval.getLastSheetIndex();
sIx++) {
+        final int firstSheetIndex = areaEval.getFirstSheetIndex();
+        final int lastSheetIndex = areaEval.getLastSheetIndex();
+        for (int sIx = firstSheetIndex; sIx <= lastSheetIndex; sIx++) {
             int height = areaEval.getHeight();
             int width = areaEval.getWidth();
             for (int rrIx=0; rrIx<height; rrIx++) {
@@ -75,7 +77,9 @@ final class CountUtils {
 	public static int countMatchingCellsInRef(RefEval refEval, I_MatchPredicate criteriaPredicate)
{
 	    int result = 0;
 	    
-	    for (int sIx = refEval.getFirstSheetIndex(); sIx <= refEval.getLastSheetIndex();
sIx++) {
+        final int firstSheetIndex = refEval.getFirstSheetIndex();
+        final int lastSheetIndex = refEval.getLastSheetIndex();
+        for (int sIx = firstSheetIndex; sIx <= lastSheetIndex; sIx++) {
 	        ValueEval ve = refEval.getInnerValueEval(sIx);
             if(criteriaPredicate.matches(ve)) {
                 result++;

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/DStarRunner.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/DStarRunner.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/DStarRunner.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/DStarRunner.java Sun Jul  3 07:20:47
2016
@@ -89,7 +89,8 @@ public final class DStarRunner implement
         }
 
         // Iterate over all DB entries.
-        for(int row = 1; row < db.getHeight(); ++row) {
+        final int height = db.getHeight();
+        for(int row = 1; row < height; ++row) {
             boolean matches = true;
             try {
                 matches = fullfillsConditions(db, row, cdb);
@@ -189,7 +190,8 @@ public final class DStarRunner implement
     private static int getColumnForString(TwoDEval db,String name)
             throws EvaluationException {
         int resultColumn = -1;
-        for(int column = 0; column < db.getWidth(); ++column) {
+        final int width = db.getWidth();
+        for(int column = 0; column < width; ++column) {
             ValueEval columnNameValueEval = db.getValue(0, column);
             String columnName = getStringFromValueEval(columnNameValueEval);
             if(name.equals(columnName)) {
@@ -215,9 +217,11 @@ public final class DStarRunner implement
         // Only one row must match to accept the input, so rows are ORed.
         // Each row is made up of cells where each cell is a condition,
         // all have to match, so they are ANDed.
-        for(int conditionRow = 1; conditionRow < cdb.getHeight(); ++conditionRow) {
+        final int height = cdb.getHeight();
+        for(int conditionRow = 1; conditionRow < height; ++conditionRow) {
             boolean matches = true;
-            for(int column = 0; column < cdb.getWidth(); ++column) { // columns are ANDed
+            final int width = cdb.getWidth();
+            for(int column = 0; column < width; ++column) { // columns are ANDed
                 // Whether the condition column matches a database column, if not it's a
                 // special column that accepts formulas.
                 boolean columnCondition = true;

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/Mode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/Mode.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/Mode.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/Mode.java Sun Jul  3 07:20:47 2016
@@ -106,7 +106,9 @@ public final class Mode implements Funct
 		}
 		if (arg instanceof RefEval) {
 			RefEval re = (RefEval) arg;
-			for (int sIx = re.getFirstSheetIndex(); sIx <= re.getLastSheetIndex(); sIx++) {
+			final int firstSheetIndex = re.getFirstSheetIndex();
+			final int lastSheetIndex = re.getLastSheetIndex();
+			for (int sIx = firstSheetIndex; sIx <= lastSheetIndex; sIx++) {
 			    collectValue(re.getInnerValueEval(sIx), temp, true);
 			}
 			return;

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/functions/TextFunction.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/functions/TextFunction.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/functions/TextFunction.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/functions/TextFunction.java Sun Jul  3 07:20:47
2016
@@ -126,9 +126,10 @@ public abstract class TextFunction imple
 		protected ValueEval evaluate(String text) {
 			StringBuilder sb = new StringBuilder();
 			boolean shouldMakeUppercase = true;
-			String lowercaseText = text.toLowerCase(Locale.ROOT);
-			String uppercaseText = text.toUpperCase(Locale.ROOT);
-			for(int i = 0; i < text.length(); ++i) {
+			final String lowercaseText = text.toLowerCase(Locale.ROOT);
+			final String uppercaseText = text.toUpperCase(Locale.ROOT);
+			final int length = text.length();
+			for(int i = 0; i < length; ++i) {
 				if (shouldMakeUppercase) {
 					sb.append(uppercaseText.charAt(i));
 				}

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/ptg/ArrayPtg.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/ptg/ArrayPtg.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/ptg/ArrayPtg.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/ptg/ArrayPtg.java Sun Jul  3 07:20:47 2016
@@ -169,18 +169,18 @@ public final class ArrayPtg extends Ptg
 	public String toFormulaString() {
 		StringBuffer b = new StringBuffer();
 		b.append("{");
-	  	for (int y=0;y<getRowCount();y++) {
+		for (int y = 0; y < _nRows; y++) {
 			if (y > 0) {
 				b.append(";");
 			}
-			for (int x=0;x<getColumnCount();x++) {
-			  	if (x > 0) {
+			for (int x = 0; x < _nColumns; x++) {
+				if (x > 0) {
 					b.append(",");
 				}
-		  		Object o = _arrayValues[getValueIndex(x, y)];
-		  		b.append(getConstantText(o));
-		  	}
-		  }
+				Object o = _arrayValues[getValueIndex(x, y)];
+				b.append(getConstantText(o));
+			}
+		}
 		b.append("}");
 		return b.toString();
 	}

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/DataFormatter.java Sun Jul  3 07:20:47
2016
@@ -563,8 +563,7 @@ public class DataFormatter implements Ob
             else if (c == 's' || c == 'S') {
                 sb.append('s');
                 // if 'M' precedes 's' it should be minutes ('m')
-                for (int i = 0; i < ms.size(); i++) {
-                    int index = ms.get(i).intValue();
+                for (int index : ms) {
                     if (sb.charAt(index) == 'M') {
                         sb.replace(index, index+1, "m");
                     }

Modified: poi/trunk/src/java/org/apache/poi/ss/usermodel/DateUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/usermodel/DateUtil.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/usermodel/DateUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/usermodel/DateUtil.java Sun Jul  3 07:20:47 2016
@@ -395,10 +395,11 @@ public class DateUtil {
              // The code above was reworked as suggested in bug 48425:
              // simple loop is more efficient than consecutive regexp replacements.
         }*/
-        StringBuilder sb = new StringBuilder(fs.length());
-        for (int i = 0; i < fs.length(); i++) {
+        final int length = fs.length();
+        StringBuilder sb = new StringBuilder(length);
+        for (int i = 0; i < length; i++) {
             char c = fs.charAt(i);
-            if (i < fs.length() - 1) {
+            if (i < length - 1) {
                 char nc = fs.charAt(i + 1);
                 if (c == '\\') {
                     switch (nc) {
@@ -435,8 +436,9 @@ public class DateUtil {
         // You're allowed something like dd/mm/yy;[red]dd/mm/yy
         //  which would place dates before 1900/1904 in red
         // For now, only consider the first one
-        if(fs.indexOf(';') > 0 && fs.indexOf(';') < fs.length()-1) {
-           fs = fs.substring(0, fs.indexOf(';'));
+        final int separatorIndex = fs.indexOf(';');
+        if(0 < separatorIndex && separatorIndex < fs.length()-1) {
+           fs = fs.substring(0, separatorIndex);
         }
 
         // Ensure it has some date letters in it

Modified: poi/trunk/src/java/org/apache/poi/ss/util/AreaReference.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/util/AreaReference.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/util/AreaReference.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/util/AreaReference.java Sun Jul  3 07:20:47 2016
@@ -101,7 +101,7 @@ public class AreaReference {
        }
      }
     
-    private boolean isPlainColumn(String refPart) {
+    private static boolean isPlainColumn(String refPart) {
         for(int i=refPart.length()-1; i>=0; i--) {
             int ch = refPart.charAt(i);
             if (ch == '$' && i==0) {

Modified: poi/trunk/src/java/org/apache/poi/util/DrawingDump.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/DrawingDump.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/DrawingDump.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/DrawingDump.java Sun Jul  3 07:20:47 2016
@@ -27,6 +27,7 @@ import java.nio.charset.Charset;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.poifs.filesystem.NPOIFSFileSystem;
+import org.apache.poi.ss.usermodel.Sheet;
 
 /**
  * Dump out the aggregated escher records
@@ -42,11 +43,11 @@ public class DrawingDump
             pw.println( "Drawing group:" );
             wb.dumpDrawingGroupRecords(true);
     
-            for (int sheetNum = 1; sheetNum <= wb.getNumberOfSheets(); sheetNum++)
+            int i = 1;
+            for (Sheet sheet : wb)
             {
-                pw.println( "Sheet " + sheetNum + ":" );
-                HSSFSheet sheet = wb.getSheetAt(sheetNum - 1);
-                sheet.dumpDrawingRecords(true, pw);
+                pw.println( "Sheet " + i + "(" + sheet.getSheetName() + "):" );
+                ((HSSFSheet) sheet).dumpDrawingRecords(true, pw);
             }
         } finally {
             wb.close();

Modified: poi/trunk/src/java/org/apache/poi/util/StringUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/StringUtil.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/StringUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/StringUtil.java Sun Jul  3 07:20:47 2016
@@ -271,8 +271,7 @@ public class StringUtil {
 	public static boolean hasMultibyte(String value) {
 		if (value == null)
 			return false;
-		for (int i = 0; i < value.length(); i++) {
-			char c = value.charAt(i);
+		for (char c : value.toCharArray()) {
 			if (c > 0xFF) {
 				return true;
 			}

Modified: poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/SignatureInfo.java Sun Jul  3
07:20:47 2016
@@ -229,7 +229,8 @@ public class SignatureInfo implements Si
                 Document doc = DocumentHelper.readDocument(signaturePart.getInputStream());
                 XPath xpath = XPathFactory.newInstance().newXPath();
                 NodeList nl = (NodeList)xpath.compile("//*[@Id]").evaluate(doc, XPathConstants.NODESET);
-                for (int i=0; i<nl.getLength(); i++) {
+                final int length = nl.getLength();
+                for (int i=0; i<length; i++) {
                     ((Element)nl.item(i)).setIdAttribute("Id", true);
                 }
                 
@@ -242,6 +243,7 @@ public class SignatureInfo implements Si
                 XMLSignature xmlSignature = xmlSignatureFactory.unmarshalXMLSignature(domValidateContext);
                 
                 // TODO: replace with property when xml-sec patch is applied
+                // workaround added in r1637283 2014-11-07
                 for (Reference ref : (List<Reference>)xmlSignature.getSignedInfo().getReferences())
{
                     SignatureFacet.brokenJvmWorkaround(ref);
                 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java Sun
Jul  3 07:20:47 2016
@@ -23,6 +23,7 @@ import org.apache.poi.ss.formula.Workboo
 import org.apache.poi.ss.formula.udf.UDFFinder;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.util.POILogFactory;
 import org.apache.poi.util.POILogger;
 import org.apache.poi.xssf.usermodel.BaseXSSFFormulaEvaluator;
@@ -100,26 +101,24 @@ public final class SXSSFFormulaEvaluator
         SXSSFFormulaEvaluator eval = new SXSSFFormulaEvaluator(wb);
         
         // Check they're all available
-        for (int i=0; i<wb.getNumberOfSheets(); i++) {
-            SXSSFSheet s = wb.getSheetAt(i);
-            if (s.areAllRowsFlushed()) {
+        for (Sheet sheet : wb) {
+            if (((SXSSFSheet)sheet).areAllRowsFlushed()) {
                 throw new SheetsFlushedException();
             }
         }
         
         // Process the sheets as best we can
-        for (int i=0; i<wb.getNumberOfSheets(); i++) {
-            SXSSFSheet s = wb.getSheetAt(i);
+        for (Sheet sheet : wb) {
             
             // Check if any rows have already been flushed out
-            int lastFlushedRowNum = s.getLastFlushedRowNum();
+            int lastFlushedRowNum = ((SXSSFSheet) sheet).getLastFlushedRowNum();
             if (lastFlushedRowNum > -1) {
                 if (! skipOutOfWindow) throw new RowFlushedException(0);
                 logger.log(POILogger.INFO, "Rows up to " + lastFlushedRowNum + " have already
been flushed, skipping");
             }
             
             // Evaluate what we have
-            for (Row r : s) {
+            for (Row r : sheet) {
                 for (Cell c : r) {
                     if (c.getCellType() == Cell.CELL_TYPE_FORMULA) {
                         eval.evaluateFormulaCell(c);

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFEvaluationWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFEvaluationWorkbook.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFEvaluationWorkbook.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFEvaluationWorkbook.java
Sun Jul  3 07:20:47 2016
@@ -118,11 +118,14 @@ public abstract class BaseXSSFEvaluation
         // Not properly referenced
         throw new RuntimeException("Book not linked for filename " + bookName);
     }
+    /* case-sensitive */
     private int findExternalLinkIndex(String bookName, List<ExternalLinksTable> tables)
{
-        for (int i=0; i<tables.size(); i++) {
-            if (tables.get(i).getLinkedFileName().equals(bookName)) {
+        int i = 0;
+        for (ExternalLinksTable table : tables) {
+            if (table.getLinkedFileName().equals(bookName)) {
                 return i+1; // 1 based results, 0 = current workbook
             }
+            i++;
         }
         return -1;
     }
@@ -131,6 +134,7 @@ public abstract class BaseXSSFEvaluation
         private FakeExternalLinksTable(String fileName) {
             this.fileName = fileName;
         }
+        @Override
         public String getLinkedFileName() {
             return fileName;
         }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java?rev=1751131&r1=1751130&r2=1751131&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFChart.java Sun Jul  3 07:20:47
2016
@@ -58,6 +58,7 @@ import org.openxmlformats.schemas.drawin
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextBody;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextField;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraph;
+import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Text;
 
@@ -274,9 +275,11 @@ public final class XSSFChart extends POI
 			.selectPath("declare namespace a='"+XSSFDrawing.NAMESPACE_A+"' .//a:t");
 		for (int m = 0; m < t.length; m++) {
 			NodeList kids = t[m].getDomNode().getChildNodes();
-			for (int n = 0; n < kids.getLength(); n++) {
-				if (kids.item(n) instanceof Text) {
-					text.append(kids.item(n).getNodeValue());
+			final int count = kids.getLength();
+			for (int n = 0; n < count; n++) {
+				Node kid = kids.item(n);
+				if (kid instanceof Text) {
+					text.append(kid.getNodeValue());
 				}
 			}
 		}

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=1751131&r1=1751130&r2=1751131&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 Jul  3 07:20:47
2016
@@ -2804,7 +2804,8 @@ public class XSSFSheet extends POIXMLDoc
         
         // check row numbers to make sure they are continuous and increasing (monotonic)
         // and srcRows does not contain null rows
-        for (int index=1; index < srcRows.size(); index++) {
+        final int size = srcRows.size();
+        for (int index=1; index < size; index++) {
             final Row curRow = srcRows.get(index);
             if (curRow == null) {
                 throw new IllegalArgumentException("srcRows may not contain null rows. Found
null row at index " + index + ".");



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


Mime
View raw message