RFR: 8221980: Simplify Optional implementation
Stuart Marks
stuart.marks at oracle.com
Thu Apr 4 20:45:46 UTC 2019
On 4/4/19 3:29 AM, Claes Redestad wrote:
> 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.
>
> Bug: https://bugs.openjdk.java.net/browse/JDK-8221980
> Webrev: http://cr.openjdk.java.net/~redestad/8221980/open.00/
>
> 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
Changes look good, thanks.
s'marks
More information about the core-libs-dev
mailing list