clebertsuconic commented on a change in pull request #2950: ARTEMIS-2604 Save 
Message decoding when unnecessary
URL: https://github.com/apache/activemq-artemis/pull/2950#discussion_r369652515
 
 

 ##########
 File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/collections/TypedProperties.java
 ##########
 @@ -372,6 +372,79 @@ private synchronized void 
forEachInternal(BiConsumer<SimpleString, PropertyValue
       }
    }
 
+   /**
+    * Performs a search among the valid key properties contained in {@code 
buffer}, starting from {@code from}
+    * assuming it to be a valid encoded {@link TypedProperties} content.
+    *
+    * @throws IllegalStateException if any not-valid property is found while 
searching the {@code key} property
+    */
+   public static boolean searchProperty(SimpleString key, ByteBuf buffer, int 
startIndex) {
 
 Review comment:
   wouldn't be less costly to just lookup for the sequence of bytes?
   
   You're still parsing the key at its exact position.
   
   if just looking for the sequence , say _HDR_SQUEDULED_TIME anywhere in the 
buffer would be enough.
   
   now if the search is more costly than the partial parsing, then it's fine.
   
   At least you're not reading the string to verify the equal object.
   
   
   if this was C, you would control to reuse the same integer every time, but 
in Java every time you do buffer.getInt(index) you will create a few bytes in 
memory.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to