Allocate ArrayList with correct size in PartitionStates
Reviewers: Ismael Juma
@@ -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()));
}
