RFR: 8299444 java.util.Set.copyOf allocates needlessly for empty input collections [v2]

Per Minborg pminborg at openjdk.org
Tue Jan 10 08:17:51 UTC 2023


On Mon, 9 Jan 2023 18:34:57 GMT, Per Minborg <pminborg at openjdk.org> wrote:

> On the note of `CHM::isEmpty`: It would be better to rewrite this method as a short-circuitable reduction of the many CounterCells' values. As soon as at least one of them are >0 then the map is not empty. In contrast, today we sum all of the values, in many cases, unnecessary.

Well, turns out this is harder than said and the original solution is not that bad after all.

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

PR: https://git.openjdk.org/jdk/pull/11847


More information about the core-libs-dev mailing list