On Thu, 24 Mar 2022 14:54:39 GMT, Roger Riggs <rri...@openjdk.org> wrote:

> It would be clearer with a comment on the constant or use the expression (the 
> compiler will evaluate it). `Integer.MAX_VALUE / 4 * 3`.

@RogerRiggs 

No, as `Integer.MAX_VALUE / 4 * 3` is actually 1610612733,

and `(int)Math.ceil(1610612733/0.75)` is actually 2147483644, 

while `Integer.MAX_VALUE` is 2147483647

Although in this situation 2147483644 and 2147483647 is same (both would be 
trimed down to 1073741824 when enter the HashMap constructor), but I think it 
be better to be more precise.

However if you want me to change it to `expectedSize >= Integer.MAX_VALUE / 4 * 
3 + 3`, then I think it acceptable, but looks a little weird.

So should we change it to `expectedSize >= Integer.MAX_VALUE / 4 * 3 + 3`?

-------------

PR: https://git.openjdk.java.net/jdk/pull/7928

Reply via email to