RFR 8207314 : Unnecessary reallocation when constructing WeakHashMap from a large Map
ivan.gerasimov at oracle.com
Sat Jul 14 05:22:52 UTC 2018
When a WeakHashMap is constructed from another Map m, then the initial
capacity is calculated as
(int) (m.size() / DEFAULT_LOAD_FACTOR) + 1.
For large values of m.size() this becomes negative due to integer overflow.
The result is that the WeakHashMap is initially constructed with the
default initial capacity 16, and then is immediately resized.
Would you please help review a trivial patch?
Thanks in advance!
With kind regards,
More information about the core-libs-dev