Implementations of PrimitiveIterator.OfInt#forEachRemaining(IntConsumer) doesn't check IntConsumer for null
Paul Sandoz
paul.sandoz at oracle.com
Wed Jun 6 15:53:17 UTC 2018
Performance should not be a concern, null checking is highly optimized by the JIT and is anyway required when the consumer is accessed in the loop.
It’s probably an oversight but FWIW these internal iterators are never exposed directly and are wrapped in spliterators and those wrappers will perform dominating null checks.
Paul.
> On Jun 5, 2018, at 1:17 PM, Андрей Турбанов <turbanoff at gmail.com> wrote:
>
> Hello.
>
> I observe that implementations of `forEachRemaining` method inside
> java.lang.CharSequence doesn't always compare IntConsumer parameter with
> null.
> Is there any reason why there is no nonNull check? Performance?
>
> Andrey Turbanov.
More information about the core-libs-dev
mailing list