On Wed, 4 Jan 2023 14:41:20 GMT, Viktor Klang <d...@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. This pull request has now been integrated. Changeset: a2a77033 Author: Viktor Klang <viktor.kl...@oracle.com> Committer: Stuart Marks <sma...@openjdk.org> URL: https://git.openjdk.org/jdk/commit/a2a7703370caf07afd88b5cfe44e1a78eed699e9 Stats: 10 lines in 3 files changed: 6 ins; 0 del; 4 mod 8299444: java.util.Set.copyOf allocates needlessly for empty input collections Reviewed-by: rriggs, shade, smarks ------------- PR: https://git.openjdk.org/jdk/pull/11847