kinow commented on a change in pull request #281:
URL: https://github.com/apache/commons-text/pull/281#discussion_r743219933



##########
File path: src/main/java/org/apache/commons/text/TextStringBuilder.java
##########
@@ -1850,7 +1850,14 @@ 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(other == null) {
+            return false;
+        }
+        if (this.size != other.size) {
+            return false;
+        }
+        return this.toString().equals(other.toString());

Review comment:
       @sebx59 your change makes the code look very similar to the code prior 
to the change that added `Arrays.equals` (which I also wouldn't have guessed to 
cause a regression here).
   
   Maybe we could just revert it instead? 
https://github.com/apache/commons-text/commit/36af8b1884a3ac7bf323a08a7d62e4a290336d2b
   
   And also add a comment in the code so we don't accidentally add the 
regression again in the code. WDYT?

##########
File path: src/test/java/org/apache/commons/text/TextStringBuilderTest.java
##########
@@ -1057,15 +1057,24 @@ public void testHashCode() {
         final TextStringBuilder sb = new TextStringBuilder();
         final int hc1a = sb.hashCode();
         final int hc1b = sb.hashCode();
-        final int emptyHc = Arrays.hashCode(sb.getBuffer());
-        assertEquals(emptyHc, hc1a);

Review comment:
       @sebx59 maybe instead of removing the asserts (this :point_up: and 
:point_down: ) we could invert them then, if the behavior has changed?




-- 
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]


Reply via email to