Serwios commented on code in PR #18107:
URL: https://github.com/apache/kafka/pull/18107#discussion_r1876537651


##########
clients/src/main/java/org/apache/kafka/clients/consumer/RangeAssignor.java:
##########
@@ -281,7 +281,7 @@ void onAssigned(String consumer, List<TopicPartition> 
newlyAssignedPartitions) {
             int numAssigned = numAssignedByConsumer.compute(consumer, (c, n) 
-> n + newlyAssignedPartitions.size());
             if (numAssigned > numPartitionsPerConsumer)
                 remainingConsumersWithExtraPartition--;
-            unassignedPartitions.removeAll(newlyAssignedPartitions);
+            newlyAssignedPartitions.forEach(unassignedPartitions::remove);

Review Comment:
   it can be faster when removing elements from a Set one by one, compared to 
using removeAll with a List
   
   When using removeAll with a List and a Set, the method iterates through the 
entire List and, for each element, checks if it exists in the Set (which can be 
slower because List doesn't have efficient lookup). 
   
   Using forEach with remove directly removes elements from the Set without the 
need for checking membership in the List repeatedly, which can be faster in 
some cases.



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