AndrewJSchofield commented on code in PR #20752:
URL: https://github.com/apache/kafka/pull/20752#discussion_r2459621417


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareCompletedFetch.java:
##########
@@ -99,10 +99,21 @@ public class ShareCompletedFetch {
     }
 
     private List<OffsetAndDeliveryCount> 
buildAcquiredRecordList(List<ShareFetchResponseData.AcquiredRecords> 
partitionAcquiredRecords) {
-        List<OffsetAndDeliveryCount> acquiredRecordList = new LinkedList<>();
+        // Setting the size of the array to the size of the first batch of 
acquired records. In case there is only 1 batch acquired, resizing would not 
happen.
+        int initialListSize = !partitionAcquiredRecords.isEmpty() ? (int) 
(partitionAcquiredRecords.get(0).lastOffset() -

Review Comment:
   In the case where the `partitionAcquiredRecords` is empty, we can just make 
an empty list and return directly. We don't need to make the `HashSet` only to 
discard it unused because the loop will not have any iterations.



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