activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franz1981 <...@git.apache.org>
Subject [GitHub] activemq-artemis pull request #1757: ARTEMIS-1586 Reduce GC pressure due to ...
Date Mon, 08 Jan 2018 20:29:00 GMT
Github user franz1981 commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/1757#discussion_r160247350
  
    --- 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 --
    
    I've implemented it in the last commit as:
    ```
       @Override
       public boolean equals(final Object other) {
          if (this == other) {
             return true;
          }
    
          if (other instanceof SimpleString) {
             SimpleString s = (SimpleString) other;
             if (s.hash != 0 && this.hash != 0) {
                if (s.hash != this.hash)
                   return false;
             }
             if (s.str != null && this.str != null) {
                return this.str.equals(s.str);
             } else {
                return ByteUtil.equals(this.data, s.data);
             }
          } else {
             return false;
          }
       }
    ```


---

Mime
View raw message