Hi Ivan,
On 4/04/2018 9:22 AM, Ivan Gerasimov wrote:
Hello!
Yet another occurrence of not-optimally pre-sized HashMap.
When java.lang.Class.enumConstantDirectory is created, the initial
capacity is set to be (2 * universe.length), which is more than
necessary in some cases.
Choosing the capacity optimally will allow us to save a few bytes with
some enum classes.
How are you defining optimal? The bug report only gives one example
where the current calculation produces a too large value. If the HashMap
itself rounds up the initial capacity to a power of 2, how much extra
space do we need compared to universe.length? Do we just need to pass
(universe.length+1) to get the smallest power of 2 greater than
universe.length?
Thanks,
David
Would you please help review this trivial fix?
BUGURL: https://bugs.openjdk.java.net/browse/JDK-8200696
WEBREV: http://cr.openjdk.java.net/~igerasim/8200696/00/webrev/