Github user franz1981 commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1757#discussion_r160344336
  
    --- Diff: 
artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java
 ---
    @@ -259,22 +281,23 @@ public boolean equals(final Object other) {
           if (other instanceof SimpleString) {
              SimpleString s = (SimpleString) other;
     
    -         if (data.length != s.data.length) {
    -            return false;
    -         }
    -
    -         for (int i = 0; i < data.length; i++) {
    -            if (data[i] != s.data[i]) {
    -               return false;
    -            }
    -         }
    -
    -         return true;
    +         return ByteUtil.equals(data, s.data);
    --- End diff --
    
    The benefit is not from the GC pov but for normal `SimpleString` usage 
inside Map/Set: if the `SimpleString` has already hash computed or it is 
string-based it won't perform array comparison (optimzed ones for sure) but 
will benenfit of `String::equals` that is intrinsified by the JVM.


---

Reply via email to