RFR: 8221980: Simplify Optional implementation
claes.redestad at oracle.com
Thu Apr 4 10:29:29 UTC 2019
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 can be simplified by refactoring so that
we only null-check once and chain through fewer methods.
While JITs are likely to inline all this and generate the optimal
code, it can fail to do so due inlining heuristics. This simplification
reduces the risk of hitting such limits, while also speeding up code
executed during startup and warmup phases.
Testing: tier1-2, verified a small improvement in startup profiles
More information about the core-libs-dev