chia7712 commented on code in PR #15924:
URL: https://github.com/apache/kafka/pull/15924#discussion_r1597473046


##########
clients/src/main/java/org/apache/kafka/common/requests/DescribeAclsResponse.java:
##########
@@ -137,15 +138,15 @@ public static List<AclBinding> 
aclBindings(List<DescribeAclsResource> resources)
         return 
resources.stream().flatMap(DescribeAclsResponse::aclBindings).collect(Collectors.toList());
     }
 
-    public static List<DescribeAclsResource> 
aclsResources(Collection<AclBinding> acls) {
-        Map<ResourcePattern, List<AccessControlEntry>> patternToEntries = new 
HashMap<>();
+    public static List<DescribeAclsResource> 
aclsResources(Iterable<AclBinding> acls) {
+        Map<ResourcePattern, Set<AccessControlEntry>> patternToEntries = new 
HashMap<>();
         for (AclBinding acl : acls) {
-            patternToEntries.computeIfAbsent(acl.pattern(), v -> new 
ArrayList<>()).add(acl.entry());
+            patternToEntries.computeIfAbsent(acl.pattern(), v -> new 
HashSet<>()).add(acl.entry());
         }
         List<DescribeAclsResource> resources = new 
ArrayList<>(patternToEntries.size());
-        for (Entry<ResourcePattern, List<AccessControlEntry>> entry : 
patternToEntries.entrySet()) {
+        for (Entry<ResourcePattern, Set<AccessControlEntry>> entry : 
patternToEntries.entrySet()) {
             ResourcePattern key = entry.getKey();
-            List<AclDescription> aclDescriptions = new ArrayList<>();
+            List<AclDescription> aclDescriptions = new ArrayList<>(128);

Review Comment:
   why not using `entry.getValue().size()`?



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