Skip to content

Commit

Permalink
Refine ListHashMap: Set initial capacity of map
Browse files Browse the repository at this point in the history
(cherry picked from commit ff62bbb)
  • Loading branch information
daniellansun committed Oct 26, 2024
1 parent 652957e commit 6af256c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/org/codehaus/groovy/util/ListHashMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

Expand Down Expand Up @@ -200,7 +201,7 @@ public int size() {
}

private Map<K,V> toMap() {
Map<K,V> m = new java.util.HashMap<>();
Map<K,V> m = new HashMap<>((int) (size / 0.75) + 1);
for (int i = 0; i < size; i += 1) {
m.put(keys[i], values[i]);
}
Expand Down

0 comments on commit 6af256c

Please sign in to comment.