Browse Source

KAFKA-8559: Allocate ArrayList with correct size in PartitionStates (#6964)

Reviewers: Ismael Juma <ismael@juma.me.uk>
pull/6967/head
wenhoujx 5 years ago committed by Ismael Juma
parent
commit
93bf965894
  1. 2
      clients/src/main/java/org/apache/kafka/common/internals/PartitionStates.java

2
clients/src/main/java/org/apache/kafka/common/internals/PartitionStates.java

@ -89,7 +89,7 @@ public class PartitionStates<S> { @@ -89,7 +89,7 @@ public class PartitionStates<S> {
* Returns the partition states in order.
*/
public List<PartitionState<S>> partitionStates() {
List<PartitionState<S>> result = new ArrayList<>();
List<PartitionState<S>> result = new ArrayList<>(map.size());
for (Map.Entry<TopicPartition, S> entry : map.entrySet()) {
result.add(new PartitionState<>(entry.getKey(), entry.getValue()));
}

Loading…
Cancel
Save