On Fri, 5 Mar 2021 18:53:29 GMT, Claes Redestad <redes...@openjdk.org> wrote:

>> This patch refactors Locale.getDefault(Category) so that the volatile field 
>> holding the Locale is typically only read once. This has a small performance 
>> advantage, and might be more robust if initialization is racy.
>
> Claes Redestad has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Fix omitted synchronized

src/java.base/share/classes/java/util/Locale.java line 946:

> 944:             Locale loc = defaultDisplayLocale; // volatile read
> 945:             if (loc == null) {
> 946:                 loc = getDisplayLocale();

Just interesting how did you check that the performance difference is because 
of volatile read, and not because of replacing of the switch by the "if"?

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

PR: https://git.openjdk.java.net/jdk/pull/2845

Reply via email to