RFR: 8238684: Override getOrDefault in immutable Map implementations

Paul Sandoz paul.sandoz at oracle.com
Fri Feb 7 16:11:33 UTC 2020


+1
Paul.

> On Feb 7, 2020, at 4:17 AM, Claes Redestad <claes.redestad at oracle.com> wrote:
> 
> Hi,
> 
> in our immutable map implementations, it's unnecessary for getOrDefault
> to check containsKey(key) in case get(key) returns null. This follows
> since null values are disallowed.
> 
> Overriding the method with an implementation is a reasonable
> optimization, for example a 50% improvement on the added
> microbenchmark. I found this opportunity when looking at startup
> profiles, so yes, there's a tiny startup improvement, too. :-)
> 
> Webrev: http://cr.openjdk.java.net/~redestad/8238684/open.00/
> Bug:    https://bugs.openjdk.java.net/browse/JDK-8238684
> 
> Testing: tier1+2 (ongoing)
> 
> Thanks!
> 
> /Claes



More information about the core-libs-dev mailing list