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

Viktor Klang duke at openjdk.org
Tue Jan 24 10:10:26 UTC 2023


> 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:

  Removing outdated comment in ImmutableCollections regarding implicit nullchecks

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/11847/files
  - new: https://git.openjdk.org/jdk/pull/11847/files/8e67eb86..b6bfa3f8

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=11847&range=02
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=11847&range=01-02

  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/11847.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11847/head:pull/11847

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


More information about the core-libs-dev mailing list