> 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 two additional 
commits since the last revision:

 - 8299444: java.util.Set.copyOf allocates needlessly for empty input 
collections
   
       Modifies ImmutableCollections.listCopy:
       Introduces a check for isEmpty to avoid allocation in the case of an 
empty input collection.
 - 8299444: java.util.Set.copyOf allocates needlessly for empty input 
collections
   
   Modifies Map.copyOf:
   Introduces a check for isEmpty to avoid allocation in the case of an empty 
input Map.

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

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

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

  Stats: 6 lines in 2 files changed: 4 ins; 0 del; 2 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

Reply via email to