While doing some benchmarking of the Gatherer API, i've found that the 
characteristics of the spliterator was not propagated by the method 
Stream.gather() making the stream slower than it should.

As an example, there is no way when reimplementing map() using a Gatherer to 
say that this intermediate operation keep the size, which is important if the 
terminal operation is toList() because if the size is known, toList() will 
presize the List and avoid the creation of an intermediary ArrayList.

See 
https://github.com/forax/we_are_all_to_gather/blob/master/src/main/java/com/gihtub/forax/wearealltogather/bench/MapGathererBenchmark.java

I think that adding a way to propagate the spliterator characteristics through 
a Gatherer would greatly improve the performance of commons streams (at least 
all the ones that end with a call to toList).

I have some idea of how to do that, but I prefer first to hear if i've overlook 
something and if improving the performance is something worth changing the API.

regards,
RĂ©mi

Reply via email to