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

Attila Szegedi attila at openjdk.org
Wed Jul 20 18:08:02 UTC 2022


On Wed, 20 Jul 2022 11:19:11 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

>> The comment was about WeekFields.of(), I misplaced the comment.
>> 
>> @szegedi All good points about modernizing code...
>> One of the reasons to ask about specific performance data is to validate the general performance impact of using lambdas. In the case of WeekFields.of(), the lambda is passed on every call to `computeIfAbsent` even if the key is present and the lambda won't be used. `WeekFields` is way-way down the long tail of frequency of use and I expect that 99% of calls are for the same one or two combinations.
>
> I agree with @RogerRiggs that performance of JDK is very important. It was one of main motivation for removing `.get` call.
> I'm not an expert in microbenchmarking, and it would require significant time/resources for me to investigate which is better.
> So I decided to revert back to original proposal (without lambda and `computeIfAbsent`) in `WeekFields`. If you think that it's better to improve code, I think we can always fill a separate issue for it.

Fair.

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

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


More information about the i18n-dev mailing list