JDK-8210280 - Unnecessary reallocation when invoking HashMap.putAll()
martinrb at google.com
Wed Dec 12 20:29:12 UTC 2018
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.
More information about the core-libs-dev