JDK-8210280 - Unnecessary reallocation when invoking HashMap.putAll()

Michal Vala mvala at redhat.com
Fri Dec 14 06:41:03 UTC 2018

Thanks, looking into that.

On 12/12/18 9:29 PM, Martin Buchholz wrote:
> When hacking on HashMap, one always needs to keep LinkedHashMap in the back
> of one's mind.
> If you use removeEldestEntry then the occupancy can never get beyond some
> limit.  It may be weird to have elements that are part of a putAll being
> removed during the call to putAll.  There's already a call to resize
> causing the backing array to grow in this (very corner) case, so it's
> arguably not introducing new weird behavior.  If removeEldestEntry is
> overridden then ideally you would only grow by doubling, but it's such a
> corner case this may not be worth doing.

Michal Vala
Red Hat Czech

More information about the core-libs-dev mailing list