-
Enhancement
-
Resolution: Fixed
-
P4
-
None
-
b16
The current code for Optional.ofNullable() null-checks the value, then calls of(), which calls new Optional(), which null-checks again via Objects.requireNonNull(). This code can be simplified by refactoring so that we only null-check once and chain through fewer methods.
The JIT is likely to inline all this and generate the optimal code, BUT it can fail to do so due inlining limits. Simplifying reduces the risk of that, while speeding up code executed during startup and warmup phases.
The JIT is likely to inline all this and generate the optimal code, BUT it can fail to do so due inlining limits. Simplifying reduces the risk of that, while speeding up code executed during startup and warmup phases.