splett2 commented on a change in pull request #11754:
URL: https://github.com/apache/kafka/pull/11754#discussion_r810532447



##########
File path: clients/src/main/java/org/apache/kafka/common/utils/Utils.java
##########
@@ -764,10 +764,7 @@ public static ByteBuffer ensureCapacity(ByteBuffer 
existingBuffer, int newLength
      */
     @SafeVarargs
     public static <T> Set<T> mkSet(T... elems) {
-        Set<T> result = new HashSet<>((int) (elems.length / 0.75) + 1);
-        for (T elem : elems)
-            result.add(elem);
-        return result;
+        return new HashSet<>(Arrays.asList(elems));

Review comment:
       It would be good to include the benchmark in the PR.
   As a comment on the benchmark, I think ms/op is too coarse of a measurement 
for the code we're benchmarking.
   
   Nanos/op is probably more appropriate.
   
   I am also wondering whether this code is called in the critical path 
anywhere. It doesn't seem to be. For instance almost all of the calls to 
`mkSet` seem to be test code or static variables.




-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to