On Sat, 18 Jun 2022 10:43:08 GMT, Andrey Turbanov <[email protected]> wrote:
> Instead of separate ConcurrentHashMap.get call, we can use result of previous
> putIfAbsent call.
src/java.base/share/classes/java/time/format/DateTimeTextProvider.java line 319:
> 317: store = prev;
> 318: }
> 319: }
You could do better here and use `computeIfAbsent` with `createStore` as its
lambda. You could even change the signature of `createStore` to take
`Entry<TemporalField, Locale>` as its parameter and then you could have this
method be:
private Object findStore(TemporalField field, Locale locale) {
return CACHE.computeIfAbsent(createEntry(field, locale),
this::createStore);
}
...
private Object createStore(Entry<TemporalField, Locale> entry) {
...
}
This applies to most other changes you made, the one in `ZoneOffset` is the
only one that's slightly different because there you have adjustment of
`ID_CACHE` too.
-------------
PR: https://git.openjdk.org/jdk/pull/9208