RFR 8200696 : Optimal initial capacity of java.lang.Class.enumConstantDirectory
Ivan Gerasimov
ivan.gerasimov at oracle.com
Wed Apr 4 23:54:15 UTC 2018
Thanks David and Claes!
I changed the expression to (int)(universe.length / 0.75f) + 1 before
pushing the fix and updated the Jira bug with more details.
With kind regards,
Ivan
On 4/3/18 11:56 PM, Claes Redestad wrote:
> Hi Ivan,
>
> looks good.
>
> Nit: maybe (int)(universe.length / 0.75f) + 1 to keep fp arithmetic to
> a minimum.
>
> /Claes
>
> On 2018-04-04 01:22, 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.
>>
>> 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/
>>
>
>
--
With kind regards,
Ivan Gerasimov
More information about the core-libs-dev
mailing list