<i18n dev> RFR: 8267670: Update java.io, java.math, and java.text to use switch expressions [v4]

Patrick Concannon pconcannon at openjdk.java.net
Wed May 26 09:39:44 UTC 2021


On Wed, 26 May 2021 09:05:34 GMT, Patrick Concannon <pconcannon at openjdk.org> wrote:

>> Hi,
>> 
>> Could someone please review my code for updating the code in the `java.io`, `java.math`, and `java.text` packages to make use of the switch expressions?
>> 
>> Kind regards,
>> Patrick
>
> Patrick Concannon has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8267670: Removed trailing whitespace

> _Mailing list message from [Brian Goetz](mailto:brian.goetz at oracle.com) on [core-libs-dev](mailto:core-libs-dev at mail.openjdk.java.net):_
> 
> In the last hunk, you convert
> 
> case Collator.IDENTICAL: toAddTo.append('='); break;
> case Collator.TERTIARY: toAddTo.append(','); break;
> case Collator.SECONDARY: toAddTo.append(';'); break;
> case Collator.PRIMARY: toAddTo.append('<'); break;
> case RESET: toAddTo.append('&'); break;
> case UNSET: toAddTo.append('?'); break;
> 
> to
> 
> case Collator.IDENTICAL -> toAddTo.append('=');
> case Collator.TERTIARY -> toAddTo.append(',');
> case Collator.SECONDARY -> toAddTo.append(';');
> case Collator.PRIMARY -> toAddTo.append('<');
> case RESET -> toAddTo.append('&');
> case UNSET -> toAddTo.append('?');
> 
> But, you can go further, pulling the toAddTo.append() call out of the switch. This was one of the benefits we anticipated with expression switches; that it would expose more opportunities to push the conditional logic farther down towards the leaves. I suspect there are other opportunities for this in this patch too.

Hi Brian, 

Thanks for your suggestion. I've incorporated it into the PR, and you can find it in commit e503ed2

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

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


More information about the i18n-dev mailing list