RFR: 8281631: HashMap copy constructor and putAll can over-allocate table [v21]
Stuart Marks
smarks at openjdk.java.net
Wed Mar 2 01:47:59 UTC 2022
On Sun, 20 Feb 2022 19:50:01 GMT, liach <duke at openjdk.java.net> wrote:
>> @liach Hi. please have a look at the latest commit.
>> do you think it be better now?
>
> Oops, didn't notice there was this helpful `init` method. Does look much more straightforward now.
I'm starting to look at this again. First, a quick note -- I don't think there should be any IdentityHashMap changes here. That uses a completely different internal structure and allocation policy, and it's kind of a distraction from the main point of this change. (As the preceding chain of comments illustrates.)
There is a question of whether IdentityHashMap ought to "allow for some growth" when copying a map, but it's hard to see how much of a problem this really is. I'd suggest focusing on getting this change done, and then (if you still have energy) to try to eradicate the `(int) (expected / 0.75) + 1` idiom that's sprinkled around the JDK.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7431
More information about the core-libs-dev
mailing list