<i18n dev> RFR: 8345668: ZoneOffset.ofTotalSeconds performance regression [v3]
Andrey Turbanov
aturbanov at openjdk.org
Thu Dec 26 17:28:35 UTC 2024
On Thu, 26 Dec 2024 16:39:58 GMT, Brett Okken <duke at openjdk.org> wrote:
>> Naoto Sato has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Fixed compile error
>
> src/java.base/share/classes/java/time/format/DateTimeTextProvider.java line 316:
>
>> 314: store = createStore(field, locale);
>> 315: CACHE.putIfAbsent(key, store);
>> 316: store = CACHE.get(key);
>
> should this be
> `store = CACHE.computeIfAbsent(key, e -> createStore(e.getKey(), e.getValue()));`
>
> That still allow the optimistic/concurrent get call to succeed most of the time (when already cached) but reduce the interactions with the map when a value is created/set/accessed the first time.
>
> Alternatively, the result of `putIfAbsent` could be checked/used to avoid the second call to `get`.
For sure we should use result of `putIfAbsent`. Let's do this for all cases. See how it was implemented in my first commit - https://github.com/openjdk/jdk/pull/9208/commits/73a2f6cb1b91f4d7ee374089f35a72ef7b94433b
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22854#discussion_r1898031238
More information about the i18n-dev
mailing list