On Mon, 24 May 2021 19:51:04 GMT, Paul Sandoz <psan...@openjdk.org> wrote:
>> Tagir F. Valeev has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Trailing whitespace removed > > src/java.base/share/classes/java/util/stream/AbstractPipeline.java line 471: > >> 469: int flags = getStreamAndOpFlags(); >> 470: long size = StreamOpFlag.SIZED.isKnown(flags) ? >> spliterator.getExactSizeIfKnown() : -1; >> 471: if (size != -1 && StreamOpFlag.SIZE_ADJUSTING.isKnown(flags) && >> !isParallel()) { > > Very nice. It's a good compromise to support only for sequential streams, > since we have no size adjusting intermediate stateless op. If that was the > case we would need to step back through the pipeline until the depth was > zero, then step forward. I think it worth a comment here to inform our future > selves if we ever add such an operation. > > Strictly speaking we only need to call `exactOutputSize` if the stage is size > adjusting. Not sure it really matters perf-wise. If we leave as is maybe add > a comment. It's hard to imagine SIZE_ADJUSTING stateless intermediate op (probably the op that duplicates every stream element like `flatMap(x -> Stream.of(x, x))` as a single op?). Nevertheless, I added the comment. Please check if it's clear enough. Thanks! ------------- PR: https://git.openjdk.java.net/jdk/pull/3427