On Thu, 18 Jan 2024 05:32:26 GMT, jmehrens <d...@openjdk.org> wrote: >> Joshua Cao has updated the pull request incrementally with one additional >> commit since the last revision: >> >> putAll presize based on sum on both map sizes > > src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java line > 1088: > >> 1086: public void putAll(Map<? extends K, ? extends V> m) { >> 1087: if (table != null) { >> 1088: tryPresize(size() + m.size()); > > Is overflow not an issue here because calling tryPresize with a negative > value will invoke tableSizeFor?
When `tableSizeFor` is called with a negative value greater than `Integer.MIN_VALUE`, it’ll just return `+1`: https://github.com/openjdk/jdk/blob/ff8cc268fdaaf85299c94088a226b73e7eaf6bdb/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java#L704-L707 This will in turn cause `tryPresize` to do nothing when `table` is already initialized. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/17116#discussion_r1457023596