RFR: 8281631: HashMap.putAll can cause redundant space waste [v3]

XenoAmess duke at openjdk.java.net
Fri Feb 11 15:34:06 UTC 2022


On Fri, 11 Feb 2022 15:04:03 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> if size were Integer.MAX_VALUE / 2; the computation would overflow

Actually will not, it must be slightly larger. it will only overflow when it be larger than Integer.MAX_VALUE * 0.75

But yes, it can overflow when there be a map as large as that.

> Using Long for the computation would avoid that and keep the expression simple.

but it be slower.

I do think a int check can do same thing, and would add it .

Thanks!

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

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


More information about the core-libs-dev mailing list