On Fri, 11 Feb 2022 13:04:38 GMT, XenoAmess <d...@openjdk.java.net> wrote:
>> 8281631: HashMap.putAll can cause redundant space waste > > XenoAmess has refreshed the contents of this pull request, and previous > commits have been removed. The incremental views will show differences > compared to the previous content of the PR. The pull request contains one new > commit since the last revision: > > 9072610: HashMap.putAll can cause redundant space waste src/java.base/share/classes/java/util/WeakHashMap.java line 247: > 245: */ > 246: private static int calculateHashMapCapacity(int size){ > 247: return size + (size + 2) / 3; Consider integer overflow; if size were Integer.MAX_VALUE / 2; the computation would overflow. The negative result would eventually throw an exception. Using Long for the computation would avoid that and keep the expression simple. ------------- PR: https://git.openjdk.java.net/jdk/pull/7431