RFR 8020016 Numerous splitereator impls do not throw NPE for null Consumers
Paul Sandoz
paul.sandoz at oracle.com
Thu Aug 1 15:49:42 UTC 2013
On Aug 1, 2013, at 4:45 PM, Henry Jen <henry.jen at oracle.com> wrote:
> In StremSpliterator:366, I assume the NULL check should be before if.
>
It saves a redundant check if the wrapping spliterator uses buffering, since the tryAdvance will also check:
public void forEachRemaining(IntConsumer consumer) {
if (buffer == null && !finished) {
Objects.requireNonNull(consumer);
init();
ph.wrapAndCopyInto((Sink.OfInt) consumer::accept, spliterator);
finished = true;
}
else {
do { } while (tryAdvance(consumer));
}
}
> There are a couple
>
> if {
> }
> else if
>
> and
>
> try {
> }
> catch
>
> Isn't the style recommended to be on the same line?
>
Depends who you talk to :-) It's a style that is used in much of the stream implementation.
Paul.
More information about the core-libs-dev
mailing list