RFR: 8281631: HashMap.putAll can cause redundant space waste [v3]

Roger Riggs rriggs at openjdk.java.net
Fri Feb 11 18:17:12 UTC 2022


On Fri, 11 Feb 2022 17:04:14 GMT, XenoAmess <duke at openjdk.java.net> wrote:

>> Performance is a lesser issue. Given all of the other computation that occurs to populate the map, this computation is in the noise.  It is also likely that with more instructions to fetch and execute and a possible branch, the integer check is slower.
>> With current hardware, the long divide dominates the cost.  Addition is almost free.
>> 
>> Code maintainability is more important; keep the source code simple and concise.
>
> @RogerRiggs 
> so you recommend `(int) Math.min(((m.size() * 4L + 2L) / 3L), Integer.MAX_VALUE)`? OK then, changed it.
> please review again, thanks!

Works for me.  Thanks

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

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


More information about the core-libs-dev mailing list