RFR: 8324573: HashMap::putAll should resize to sum of both map sizes

Joshua Cao duke at openjdk.org
Wed Jan 24 21:01:26 UTC 2024


On Wed, 24 Jan 2024 19:55:27 GMT, Chen Liang <liach at openjdk.org> wrote:

> Then we might need some statistics on how often `putAll` replaces existing mappings, ranging from none at all to completely. For example, `Collectors.toMap` would never replace existing mappings, even though it doesn't use `putAll` (it can probably call putAll and throw exception if the new size isn't 2 old sizes added up)
> 
> The current allocation assumes putting replaces all existing mappings, which I don't think is quite applicable.

I do not think we care whetherd mappings are getting replaced. We care about the number of unique keys between the two maps, which determines the final size of the map.

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

PR Comment: https://git.openjdk.org/jdk/pull/17544#issuecomment-1908904298


More information about the core-libs-dev mailing list