6.1.0
💡 Improvements
-
If one has a
Stream<Optional<T>> stream
of sizeN
and doesstream.flatMap(Optional::stream)
, you’ll end up allocatingN
extra streams — one for eachOptional
input element. WhenN
is large, those allocations can cause extra GC cycles and pauses if allocation rate is high enough leading to issues with latency, throughput, and allocation sensitive code paths.Stream.filter(Optional::isPresent).map(Optional::get)
is more efficient thanStream.flatMap(Optional::stream)
as it does not allocate a newStream
for every element in the stream. (#2946)