RFR: 8322149: ConcurrentHashMap copy constructor should not transfer from old table on presizing [v2]

Volker Simonis simonis at openjdk.org
Thu Jan 11 09:42:25 UTC 2024


On Mon, 8 Jan 2024 20:27:59 GMT, Joshua Cao <duke at openjdk.org> wrote:

> We don't need to compute max() here. [tryPresize()](https://github.com/openjdk/jdk/blob/8a4dc79e1a40e7115e2971af81623b6b0368f41c/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java#L2397) does that already.

The code you reference is only executed if `table == null` but in this case we know it is not `null` because we only call `tryPresize()` if `table != null`.

In general, it's hard fro me to understand what `tryPresize(int size)` is doing and if its `size` argument is supposed to contain the additional number of elements which will be inserted into the hash map or if it is a hint for the new total size of the hash map. Can you explain?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17116#discussion_r1448566797


More information about the core-libs-dev mailing list