Re: RFR: 8285947: Avoid redundant HashMap.containsKey calls in ZoneName

2022-05-02 Thread Roger Riggs
On Fri, 29 Apr 2022 06:31:22 GMT, Andrey Turbanov wrote: > `Map.containsKey` call is sometimes unnecessary, when it's known that Map > doesn't contain `null` values. > Instead we can just use Map.get and compare result with `null`. > I found one of such place, where Map.containsKey calls could

Re: RFR: 8285947: Avoid redundant HashMap.containsKey calls in ZoneName

2022-05-02 Thread Naoto Sato
On Fri, 29 Apr 2022 06:31:22 GMT, Andrey Turbanov wrote: > `Map.containsKey` call is sometimes unnecessary, when it's known that Map > doesn't contain `null` values. > Instead we can just use Map.get and compare result with `null`. > I found one of such place, where Map.containsKey calls could

Re: RFR: 8285947: Avoid redundant HashMap.containsKey calls in ZoneName

2022-04-30 Thread Stephen Colebourne
On Fri, 29 Apr 2022 06:31:22 GMT, Andrey Turbanov wrote: > `Map.containsKey` call is sometimes unnecessary, when it's known that Map > doesn't contain `null` values. > Instead we can just use Map.get and compare result with `null`. > I found one of such place, where Map.containsKey calls could

Re: RFR: 8285947: Avoid redundant HashMap.containsKey calls in ZoneName

2022-04-29 Thread Andrey Turbanov
On Fri, 29 Apr 2022 06:31:22 GMT, Andrey Turbanov wrote: > `Map.containsKey` call is sometimes unnecessary, when it's known that Map > doesn't contain `null` values. > Instead we can just use Map.get and compare result with `null`. > I found one of such place, where Map.containsKey calls could

Re: RFR: 8285947: Avoid redundant HashMap.containsKey calls in ZoneName

2022-04-29 Thread Andrey Turbanov
On Fri, 29 Apr 2022 20:45:20 GMT, Andrey Turbanov wrote: >> src/java.base/share/classes/java/time/format/ZoneName.java.template line 60: >> >>> 58: >>> 59: public static String toZid(String zid) { >>> 60: return aliases.getOrDefault(zid, zid); >> >> Is the behavior if zid == null

Re: RFR: 8285947: Avoid redundant HashMap.containsKey calls in ZoneName

2022-04-29 Thread Andrey Turbanov
On Fri, 29 Apr 2022 20:36:59 GMT, Roger Riggs wrote: >aliases.getOrDefault will throw NPE on null No, It will not. `aliases` is a HashMap. And HashMap supports null values and keys. - PR: https://git.openjdk.java.net/jdk/pull/8463

Re: RFR: 8285947: Avoid redundant HashMap.containsKey calls in ZoneName

2022-04-29 Thread Roger Riggs
On Fri, 29 Apr 2022 06:31:22 GMT, Andrey Turbanov wrote: > `Map.containsKey` call is sometimes unnecessary, when it's known that Map > doesn't contain `null` values. > Instead we can just use Map.get and compare result with `null`. > I found one of such place, where Map.containsKey calls could

RFR: 8285947: Avoid redundant HashMap.containsKey calls in ZoneName

2022-04-29 Thread Andrey Turbanov
`Map.containsKey` call is sometimes unnecessary, when it's known that Map doesn't contain `null` values. Instead we can just use Map.get and compare result with `null`. I found one of such place, where Map.containsKey calls could be eliminated - `java.time.format.ZoneName`. it gives a bit of