Re: RFR: JDK-8277095 : Empty streams create too many objects [v2]

2022-03-30 Thread Muescha
On Tue, 16 Nov 2021 20:53:26 GMT, kabutz wrote: >> This is a draft proposal for how we could improve stream performance for the >> case where the streams are empty. Empty collections are common-place. If we >> iterate over them with an Iterator, we would have to create one small >> Iterator

Re: RFR: JDK-8277095 : Empty streams create too many objects [v2]

2022-02-09 Thread kabutz
On Tue, 16 Nov 2021 20:53:26 GMT, kabutz wrote: >> This is a draft proposal for how we could improve stream performance for the >> case where the streams are empty. Empty collections are common-place. If we >> iterate over them with an Iterator, we would have to create one small >> Iterator

Re: RFR: JDK-8277095 : Empty streams create too many objects [v2]

2022-01-12 Thread kabutz
On Tue, 16 Nov 2021 20:53:26 GMT, kabutz wrote: >> This is a draft proposal for how we could improve stream performance for the >> case where the streams are empty. Empty collections are common-place. If we >> iterate over them with an Iterator, we would have to create one small >> Iterator

Re: RFR: JDK-8277095 : Empty streams create too many objects [v2]

2021-12-14 Thread kabutz
On Tue, 16 Nov 2021 20:53:26 GMT, kabutz wrote: >> This is a draft proposal for how we could improve stream performance for the >> case where the streams are empty. Empty collections are common-place. If we >> iterate over them with an Iterator, we would have to create one small >> Iterator

Re: RFR: JDK-8277095 : Empty streams create too many objects [v2]

2021-11-16 Thread kabutz
> This is a draft proposal for how we could improve stream performance for the > case where the streams are empty. Empty collections are common-place. If we > iterate over them with an Iterator, we would have to create one small > Iterator object (which could often be eliminated) and if it is

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-16 Thread kabutz
On Fri, 5 Nov 2021 12:53:46 GMT, kabutz wrote: > This is a draft proposal for how we could improve stream performance for the > case where the streams are empty. Empty collections are common-place. If we > iterate over them with an Iterator, we would have to create one small > Iterator object

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread kabutz
On Mon, 15 Nov 2021 18:23:16 GMT, Philippe Marschall wrote: > > ``` > > 3. I made many methods just return `this` after checking for operated on > > and closed: > > ``` > > Reading the Javadoc again I'm not sure this is allowed. The method Javadoc > doesn't clearly say it but the package

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread kabutz
On Mon, 15 Nov 2021 18:08:22 GMT, Philippe Marschall wrote: > I have a similar project at > [empty-streams](https://github.com/marschall/empty-streams). A couple of > notes: > > 1. I found the need for streams to be stateful. I had need for the following > state: > >1. closed >

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread Philippe Marschall
On Mon, 15 Nov 2021 18:08:22 GMT, Philippe Marschall wrote: > 3. I made many methods just return `this` after checking for operated on > and closed: Reading the Javadoc again I'm not sure this is allowed. The method Javadoc doesn't clearly say it but the package Javadoc for intermediate

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread Philippe Marschall
On Fri, 5 Nov 2021 12:53:46 GMT, kabutz wrote: > This is a draft proposal for how we could improve stream performance for the > case where the streams are empty. Empty collections are common-place. If we > iterate over them with an Iterator, we would have to create one small > Iterator object

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread Michael Bien
On Sun, 7 Nov 2021 06:53:12 GMT, kabutz wrote: >>> The net effect of this change might depend on your workload. If you call >>> stream() on empty collections that have cheap isEmpty(), this change will >>> likely improve performance and reduce waste. However, this same change >>> might do the

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread kabutz
On Wed, 10 Nov 2021 07:45:27 GMT, Anthony Vanelverdinghe wrote: >> @kabutz I agree that i wouldn't consider it clean code to use a stream like >> i put into the example. I only brought it up because it might break existing >> code, since i think streams are expected to be lazy. Interesting to

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread Anthony Vanelverdinghe
On Sun, 7 Nov 2021 07:51:06 GMT, Michael Bien wrote: >>> wouldn't this make streams no longer lazy if the collection is empty? >>> >>> ```java >>> List list = new ArrayList<>(); >>> Stream stream = list.stream(); >>> >>> list.addAll(List.of("one", "two", "three")); >>>

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread kabutz
On Sun, 7 Nov 2021 06:26:22 GMT, kabutz wrote: >> (immutable collections could override stream() instead, since they don't >> have that problem) > >> The net effect of this change might depend on your workload. If you call >> stream() on empty collections that have cheap isEmpty(), this change

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread kabutz
On Sun, 7 Nov 2021 04:26:13 GMT, Michael Bien wrote: >> wouldn't this make streams no longer lazy if the collection is empty? >> >> List list = new ArrayList<>(); >> Stream stream = list.stream(); >> >> list.addAll(List.of("one", "two", "three")); >> >>

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread Michael Bien
On Sat, 6 Nov 2021 22:03:26 GMT, Pavel Rappo wrote: >> This is a draft proposal for how we could improve stream performance for the >> case where the streams are empty. Empty collections are common-place. If we >> iterate over them with an Iterator, we would have to create one small >>

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread Michael Bien
On Sun, 7 Nov 2021 03:53:29 GMT, Michael Bien wrote: >> src/java.base/share/classes/java/util/Collection.java line 743: >> >>> 741: */ >>> 742: default Stream stream() { >>> 743: if (isEmpty()) return Stream.empty(); >> >> The net effect of this change might depend on your

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread kabutz
On Sat, 13 Nov 2021 16:59:10 GMT, liach wrote: >> This is a draft proposal for how we could improve stream performance for the >> case where the streams are empty. Empty collections are common-place. If we >> iterate over them with an Iterator, we would have to create one small >> Iterator

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread liach
On Fri, 5 Nov 2021 12:53:46 GMT, kabutz wrote: > This is a draft proposal for how we could improve stream performance for the > case where the streams are empty. Empty collections are common-place. If we > iterate over them with an Iterator, we would have to create one small > Iterator object

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread kabutz
On Fri, 5 Nov 2021 12:53:46 GMT, kabutz wrote: > This is a draft proposal for how we could improve stream performance for the > case where the streams are empty. Empty collections are common-place. If we > iterate over them with an Iterator, we would have to create one small > Iterator object

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread Laurent Bourgès
On Fri, 5 Nov 2021 12:53:46 GMT, kabutz wrote: > This is a draft proposal for how we could improve stream performance for the > case where the streams are empty. Empty collections are common-place. If we > iterate over them with an Iterator, we would have to create one small > Iterator object

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread kabutz
On Sat, 6 Nov 2021 17:23:34 GMT, Pavel Rappo wrote: > Streams are closeable, and a terminal operation may be invoked on a given > stream only once. Thus, shouldn't the third line in both of the examples > below throw `IllegalStateException`? > > ``` > Stream empty = Stream.empty(); >

Re: RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread Pavel Rappo
On Fri, 5 Nov 2021 12:53:46 GMT, kabutz wrote: > This is a draft proposal for how we could improve stream performance for the > case where the streams are empty. Empty collections are common-place. If we > iterate over them with an Iterator, we would have to create one small > Iterator object

RFR: JDK-8277095 : Empty streams create too many objects

2021-11-15 Thread kabutz
This is a draft proposal for how we could improve stream performance for the case where the streams are empty. Empty collections are common-place. If we iterate over them with an Iterator, we would have to create one small Iterator object (which could often be eliminated) and if it is empty we