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

    https://github.com/apache/activemq-artemis/pull/1786#discussion_r162262393
  
    --- Diff: 
artemis-commons/src/main/java/org/apache/activemq/artemis/api/core/SimpleString.java
 ---
    @@ -361,13 +371,68 @@ public int hashCode() {
           }
        }
     
    +   private static SimpleString[] splitWithCachedString(final SimpleString 
simpleString, final int delim) {
    +      final String str = simpleString.str;
    +      final byte[] data = simpleString.data;
    +      final int length = str.length();
    +      List<SimpleString> all = null;
    +      int index = 0;
    +      while (index < length) {
    +         final int delimIndex = str.indexOf(delim, index);
    +         if (delimIndex == -1) {
    +            //just need to add the last one
    +            break;
    +         } else {
    +            all = addSimpleStringPart(all, data, index, delimIndex);
    +         }
    +         index = delimIndex + 1;
    +      }
    +      if (all == null) {
    +         return new SimpleString[]{simpleString};
    +      } else {
    +         // Adding the last one
    +         all = addSimpleStringPart(all, data, index, length);
    +         // Converting it to arrays
    +         final SimpleString[] parts = new SimpleString[all.size()];
    +         return all.toArray(parts);
    +      }
    +   }
    +
    +   private static List<SimpleString> 
addSimpleStringPart(List<SimpleString> all,
    +                                                         final byte[] data,
    +                                                         final int 
startIndex,
    +                                                         final int 
endIndex) {
    +      final int expectedLength = endIndex - startIndex;
    +      final SimpleString ss;
    +      if (expectedLength == 0) {
    +         ss = EMPTY;
    --- End diff --
    
    How we sure, that expectedLength 0 shouldn't equal null?


---

Reply via email to