Re: RFR: 8238684: Override getOrDefault in immutable Map implementations

2020-02-07 Thread Paul Sandoz
+1 Paul. > On Feb 7, 2020, at 4:17 AM, Claes Redestad 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 impleme

Re: RFR: 8238684: Override getOrDefault in immutable Map implementations

2020-02-07 Thread Claes Redestad
Hi Rémi, On 2020-02-07 15:21, Remi Forax wrote: Hi Claes, looks good, thanks! it can be written in a less Doug Lea-ish way like this V v = get(key); return (v != null)? v: default; I believe it using the same number of bytecodes :) with a ALOAD instead of a DUP yes, but I have no s

Re: RFR: 8238684: Override getOrDefault in immutable Map implementations

2020-02-07 Thread Remi Forax
: "core-libs-dev" > Envoyé: Vendredi 7 Février 2020 13:17:40 > Objet: RFR: 8238684: Override getOrDefault in immutable Map implementations > Hi, > > in our immutable map implementations, it's unnecessary for getOrDefault > to check containsKey(key) in case get(key) r

RFR: 8238684: Override getOrDefault in immutable Map implementations

2020-02-07 Thread Claes Redestad
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 adde