On Tue, 24 Jan 2023 19:34:48 GMT, Viktor Klang wrote:
>> Thanks @szegedi for catching this and @viktorklang-ora for fixing it. I like
>> having comments like this in cases where we need to throw NPE for null and
>> for which there's no explicit `Objects.requireNonNull`. We've had cases in
>> t
On Tue, 24 Jan 2023 19:43:14 GMT, Viktor Klang 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.
>
> Viktor Klan
On Tue, 24 Jan 2023 18:00:30 GMT, Stuart Marks wrote:
>> src/java.base/share/classes/java/util/ImmutableCollections.java line 174:
>>
>>> 172: return List.of();
>>> 173: } else {
>>> 174: return (List)List.of(coll.toArray()); // implicit
>>> nullcheck of coll
>>
On Tue, 24 Jan 2023 19:38:58 GMT, Viktor Klang 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.
>
> Viktor Klan
> 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
On Sun, 22 Jan 2023 15:20:18 GMT, Attila Szegedi 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 Immuta
On Tue, 24 Jan 2023 13:40:37 GMT, Viktor Klang wrote:
>> `coll instanceof ListN list` should work.
>
> @forax @stuart-marks Yeah, that works. It's unfortunate that it's not
> possible to match on the actual (generic) type, as then both sides of the ||
> could use type unification to avoid havin
On Tue, 24 Jan 2023 11:07:07 GMT, Rémi Forax wrote:
>> @stuart-marks Sorry, missed this notification. I initially had the same
>> idea, but decided against it because it forces me to suppress "rawtypes"
>> since `coll instanceof ListN` is not considered to be a rawtype, but `coll
>> instanceof
> 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
On Tue, 24 Jan 2023 10:23:14 GMT, Viktor Klang wrote:
>> src/java.base/share/classes/java/util/ImmutableCollections.java line 169:
>>
>>> 167: @SuppressWarnings("unchecked")
>>> 168: static List listCopy(Collection coll) {
>>> 169: if (coll instanceof List12 || (coll instanceof
On Sun, 22 Jan 2023 15:20:18 GMT, Attila Szegedi 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 Immuta
On Mon, 9 Jan 2023 18:26:56 GMT, Stuart Marks 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 Immutable
> 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
On Mon, 9 Jan 2023 08:33:09 GMT, Viktor Klang 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.
>
> Viktor Klang
On Mon, 9 Jan 2023 18:34:57 GMT, Per Minborg wrote:
> On the note of `CHM::isEmpty`: It would be better to rewrite this method as a
> short-circuitable reduction of the many CounterCells' values. As soon as at
> least one of them are >0 then the map is not empty. In contrast, today we sum
> al
On Mon, 9 Jan 2023 18:34:57 GMT, Per Minborg 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 ImmutableC
On Mon, 9 Jan 2023 08:33:09 GMT, Viktor Klang 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.
>
> Viktor Klang
On Mon, 9 Jan 2023 08:33:09 GMT, Viktor Klang 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.
>
> Viktor Klang
On Mon, 9 Jan 2023 08:33:09 GMT, Viktor Klang 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.
>
> Viktor Klang
On Mon, 9 Jan 2023 17:09:02 GMT, Sergey Bylokhov 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 Immuta
On Mon, 9 Jan 2023 08:33:09 GMT, Viktor Klang 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.
>
> Viktor Klang
On Thu, 5 Jan 2023 01:02:11 GMT, Sergey Bylokhov wrote:
>> There's no regression test. However, with the current code (prior to this
>> change) a call to `Set.of(zeroLengthArray)` returns the same instance as
>> `Set.of()`, so it's difficult to write a simple functional test for this
>> change
> 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
On Thu, 5 Jan 2023 01:02:11 GMT, Sergey Bylokhov wrote:
>> There's no regression test. However, with the current code (prior to this
>> change) a call to `Set.of(zeroLengthArray)` returns the same instance as
>> `Set.of()`, so it's difficult to write a simple functional test for this
>> change
On Wed, 4 Jan 2023 19:39:23 GMT, Stuart Marks wrote:
> so it's difficult to write a simple functional test for this change.
It is possible to track that for some "custom" and empty collection the only
method will be called is `isEmpty` and nothing else. Not sure how it is useful
or not.
-
On Wed, 4 Jan 2023 14:41:20 GMT, Viktor Klang 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.
There's no regressio
On Wed, 4 Jan 2023 14:41:20 GMT, Viktor Klang 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.
Looks okay. This rel
On Wed, 4 Jan 2023 15:20:10 GMT, Pavel Rappo 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.
>
> Curious: how
On Wed, 4 Jan 2023 14:41:20 GMT, Viktor Klang 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.
Curious: how bad was
On Wed, 4 Jan 2023 14:41:20 GMT, Viktor Klang 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.
LGTM
-
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.
-
Commit messages:
- 8299444: java.util.Set.copyOf allocates needlessly
31 matches
Mail list logo