RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v24]

Stuart Marks smarks at openjdk.java.net
Fri Mar 4 01:14:05 UTC 2022


On Thu, 3 Mar 2022 15:46:37 GMT, XenoAmess <duke at openjdk.java.net> wrote:

>> 8281631: HashMap copy constructor and putAll can over-allocate table
>
> XenoAmess has updated the pull request incrementally with one additional commit since the last revision:
> 
>   cast several float to double before calculation

src/java.base/share/classes/java/util/WeakHashMap.java line 469:

> 467:         Entry<K,V> e = tab[i];
> 468:         tab[i] = new Entry<>(k, value, queue, h, e);
> 469:         if (++size > threshold)

Good catch here, by the way. The old code clearly expanded the map prematurely.

-------------

PR: https://git.openjdk.java.net/jdk/pull/7431


More information about the core-libs-dev mailing list