michaelandrepearce commented on issue #2427: ARTEMIS-2170 Optimized 
CoreMessage's checkProperties and cleanupInternalProperties methods
URL: https://github.com/apache/activemq-artemis/pull/2427#issuecomment-456323566
 
 
   @franz1981 
   
   On the predicate logic, there is a small enhancement you could make, if you 
added the following method to SimpleString
   
   ```
   
      public boolean startsWithButNotEqual(final SimpleString other) {
         //Equal so return false
         if (this == other) {
            return false;
         }
         byte[] otherdata = other.data;
   
         if (otherdata.length > data.length) {
            return false;
         }
   
         for (int i = 0; i < otherdata.length; i++) {
            if (data[i] != otherdata[i]) {
               return false;
            }
         }
   
         //Equal so return false
         if (otherdata.length == data.length) {
            return false;
         }
   
         return true;
      }
   ```
   
   Then you could make the predicate, this would avoid having to do an equals 
check if there is a match, as the equal check can be combined with the 
startswith.
   
   ```
      private static final Predicate<SimpleString> 
INTERNAL_PROPERTY_NAMES_PREDICATE =
         name -> name.startsWithButNotEqual(Message.HDR_ROUTE_TO_IDS) || 
name.startsWithButNotEqual(Message.HDR_ROUTE_TO_ACK_IDS);
   ```
   
   i think its over-optimisation personally, but if you are concerned, you 
could look to something like that.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to