schlosna commented on code in PR #12782:
URL: https://github.com/apache/kafka/pull/12782#discussion_r1717239218


##########
clients/src/main/java/org/apache/kafka/common/requests/MetadataResponse.java:
##########
@@ -177,12 +177,15 @@ public static PartitionInfo 
toPartitionInfo(PartitionMetadata metadata, Map<Inte
     }
 
     private static Node[] convertToNodeArray(List<Integer> replicaIds, 
Map<Integer, Node> nodesById) {
-        return replicaIds.stream().map(replicaId -> {
+        Node[] nodes = new Node[replicaIds.size()];
+        for (int i = 0; i < replicaIds.size(); i++) {
+            Integer replicaId = replicaIds.get(i);

Review Comment:
   We could unbox this to `int`, but it would be boxed back to `Integer` on the 
next line as argument to `nodesById.get(replicaId)` for `Map<Integer, Node> 
nodesById`. For `replicaId` < 128 (unless one increases/decreases 
`java.lang.Integer.IntegerCache.high` system property) this would be cached by 
`java.lang.Integer`'s internal cache, otherwise it would allocate a new 
`Integer`.
   
   I'm inclined to leave it as `Integer replicaId = replicaIds.get(i);` to 
avoid that roundtrip.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to