<i18n dev> RFR: 8268469: Update java.time to use switch expressions [v3]

Patrick Concannon pconcannon at openjdk.java.net
Tue Jun 22 09:59:01 UTC 2021


On Wed, 16 Jun 2021 10:58:22 GMT, Stephen Colebourne <scolebourne at openjdk.org> wrote:

>> Patrick Concannon has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision:
>> 
>>  - 8268469: Removed excessive spacing; corrected misplaced comments
>>  - Merge remote-tracking branch 'origin/master' into JDK-8268469
>>  - Merge remote-tracking branch 'origin/master' into JDK-8268469
>>  - 8268469: Update java.time to use switch expressions
>
> src/java.base/share/classes/java/time/LocalDate.java line 607:
> 
>> 605:         if (field instanceof ChronoField chronoField) {
>> 606:             if (chronoField.isDateBased()) {
>> 607:                 int n = switch (chronoField) {
> 
> This logic is harder to read than before, and it requires the CPU to perform an extra branch on `(n == -1)`. It should just be a `return switch ...`

Reverted logic as requested. See 24ae9e5

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

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


More information about the i18n-dev mailing list