<i18n dev> RFR: 8288723: Avoid redundant ConcurrentHashMap.get call in java.time [v2]

liach duke at openjdk.org
Sun Jul 3 20:49:42 UTC 2022


On Wed, 22 Jun 2022 21:29:50 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

>> Instead of separate ConcurrentHashMap.get call, we can use result of previous putIfAbsent call.
>
> Andrey Turbanov has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8288723: Avoid redundant ConcurrentHashMap.get call in java.time
>   use computeIfAbsent where lambda could be short and static

src/java.base/share/classes/java/time/format/DateTimeTextProvider.java line 312:

> 310:     private Object findStore(TemporalField field, Locale locale) {
> 311:         Entry<TemporalField, Locale> key = createEntry(field, locale);
> 312:         return CACHE.computeIfAbsent(key, e -> createStore(e.getKey(), e.getValue()));

If `createStore` can be static, the call site will only have to construct a constant lambda than having to pass `this` to construct a new instance on every call

-------------

PR: https://git.openjdk.org/jdk/pull/9208


More information about the i18n-dev mailing list