sebx59 commented on a change in pull request #281:
URL: https://github.com/apache/commons-text/pull/281#discussion_r839578006
##########
File path: src/main/java/org/apache/commons/text/TextStringBuilder.java
##########
@@ -1850,7 +1850,25 @@ public boolean equals(final Object obj) {
* @return true if the builders contain the same characters in the same
order
*/
public boolean equals(final TextStringBuilder other) {
- return other != null && Arrays.equals(buffer, other.buffer);
+ if (this == other) {
+ return true;
+ }
+ if (other == null) {
+ return false;
+ }
+ if (this.size != other.size) {
+ return false;
+ }
+ // Be aware not to use Arrays.equals(buffer, other.buffer) for
equals() method
+ // as length of the buffers may be different (TEXT-211)
Review comment:
size of the TextStringBuilder cannot be different but sizes of their
buffers can as the size represents the real number of characters of the
TextStringBuilder but the buffer may have been initialized with another
capacity.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]