Integrated: 8299444 java.util.Set.copyOf allocates needlessly for empty input collections
Viktor Klang
duke at openjdk.org
Thu Jan 26 18:19:28 UTC 2023
On Wed, 4 Jan 2023 14:41:20 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.
This pull request has now been integrated.
Changeset: a2a77033
Author: Viktor Klang <viktor.klang at oracle.com>
Committer: Stuart Marks <smarks at 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
More information about the core-libs-dev
mailing list