From 3eec3147196d53d4a514bca531e26233e6c407ff Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Sun, 31 Aug 2014 19:53:53 +0000 Subject: [PATCH] Bug 55280: Don't repeatedely fetch the size of the CTMergeCells object as this is a costly operation with XMLBeans git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1621631 13f79535-47bb-0310-9956-ffa450edef68 --- src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 29c391ee6..543263f7a 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -1579,8 +1579,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet { public void removeMergedRegion(int index) { CTMergeCells ctMergeCells = worksheet.getMergeCells(); - CTMergeCell[] mergeCellsArray = new CTMergeCell[ctMergeCells.sizeOfMergeCellArray() - 1]; - for (int i = 0 ; i < ctMergeCells.sizeOfMergeCellArray() ; i++) { + int size = ctMergeCells.sizeOfMergeCellArray(); + CTMergeCell[] mergeCellsArray = new CTMergeCell[size - 1]; + for (int i = 0 ; i < size ; i++) { if (i < index) { mergeCellsArray[i] = ctMergeCells.getMergeCellArray(i); }