From: Javen O'Neal Date: Mon, 9 May 2016 05:46:14 +0000 (+0000) Subject: bug 59443: exit early on setAddress if address is the same X-Git-Tag: REL_3_15_BETA2~259 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8702bc1f885f962f224f66a5ee9bd87701d98dde;p=poi.git bug 59443: exit early on setAddress if address is the same git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1742881 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/ss/util/CellAddress.java b/src/java/org/apache/poi/ss/util/CellAddress.java index 76c0bb4934..b6307556f8 100644 --- a/src/java/org/apache/poi/ss/util/CellAddress.java +++ b/src/java/org/apache/poi/ss/util/CellAddress.java @@ -145,10 +145,9 @@ public class CellAddress implements Comparable { return false; } - CellAddress cr = (CellAddress) o; - return _row == cr._row - && _col == cr._col - ; + CellAddress other = (CellAddress) o; + return _row == other._row && + _col == other._col; } @Override diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java index f71cbcb955..4449757a76 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFComment.java @@ -143,6 +143,10 @@ public class XSSFComment implements Comment { @Override public void setAddress(CellAddress address) { CellAddress oldRef = new CellAddress(_comment.getRef()); + if (address.equals(oldRef)) { + // nothing to do + return; + } _comment.setRef(address.formatAsString()); _comments.referenceUpdated(oldRef, _comment); @@ -161,6 +165,8 @@ public class XSSFComment implements Comment { /** * Set the column of the cell that contains the comment + * + * If changing both row and column, use {@link #setAddress}. * * @param col the 0-based column of the cell that contains the comment */ @@ -171,6 +177,8 @@ public class XSSFComment implements Comment { /** * Set the row of the cell that contains the comment + * + * If changing both row and column, use {@link #setAddress}. * * @param row the 0-based row of the cell that contains the comment */