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

Roger Riggs rriggs at openjdk.org
Tue Jan 24 19:43:15 UTC 2023


On Tue, 24 Jan 2023 19:38:58 GMT, Viktor Klang <duke at openjdk.org> wrote:

>> Currently Set.copyOf allocates both a HashSet and a new empty array when the input collection is empty.
>> 
>> This patch avoids allocating anything for the case where the parameter collection's isEmpty returns true.
>
> Viktor Klang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Adding comment clarifying where implicit nullchecks are made in Set and Map copyOf

Marked as reviewed by rriggs (Reviewer).

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

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


More information about the core-libs-dev mailing list