mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8322149: ConcurrentHashMap smarter presizing for copy constructor and putAll
Reviewed-by: shade, simonis
This commit is contained in:
parent
fb822e49f2
commit
c432dc008b
2 changed files with 26 additions and 3 deletions
|
@ -848,7 +848,7 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
|||
* @param m the map
|
||||
*/
|
||||
public ConcurrentHashMap(Map<? extends K, ? extends V> m) {
|
||||
this.sizeCtl = DEFAULT_CAPACITY;
|
||||
this(m.size());
|
||||
putAll(m);
|
||||
}
|
||||
|
||||
|
@ -1084,7 +1084,9 @@ public class ConcurrentHashMap<K,V> extends AbstractMap<K,V>
|
|||
* @param m mappings to be stored in this map
|
||||
*/
|
||||
public void putAll(Map<? extends K, ? extends V> m) {
|
||||
tryPresize(m.size());
|
||||
if (table != null) {
|
||||
tryPresize(size() + m.size());
|
||||
}
|
||||
for (Map.Entry<? extends K, ? extends V> e : m.entrySet())
|
||||
putVal(e.getKey(), e.getValue(), false);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue