On Sun, 22 Jan 2023 15:20:18 GMT, Attila Szegedi <[email protected]> wrote:
>> 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.
>
> src/java.base/share/classes/java/util/ImmutableCollections.java line 174:
>
>> 172: return List.of();
>> 173: } else {
>> 174: return (List<E>)List.of(coll.toArray()); // implicit
>> nullcheck of coll
>
> The comment is no longer relevant here, as it now happens on line 171.
@szegedi Nice catch, Attila. Corrected!
-------------
PR: https://git.openjdk.org/jdk/pull/11847