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

Stuart Marks smarks at openjdk.java.net
Fri Mar 11 03:10:47 UTC 2022


On Fri, 11 Mar 2022 01:28:13 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:
> 
>   refine test

@RogerRiggs Good point about `Integer` being value-based. We should probably use `String` instead.

@XenoAmess I don't think we need `KeyStructure`. It's probably sufficient to change the map types to `Map<String, String>` and then use `String.valueOf(i)` to generate strings to use as keys and values. (If we did need something like `KeyStructure`, it would be a perfect use of record classes.)

Also, I don't think `tableSizeFor` needs quite as many cases. It's sufficient to test the edge and boundary cases.

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

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


More information about the core-libs-dev mailing list