Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8267670: Update java.io, java.math, and java.text to use switch expressions #4182

Closed
wants to merge 11 commits into from

Conversation

pconcannon
Copy link
Contributor

@pconcannon pconcannon commented May 25, 2021

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


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8267670: Update java.io, java.math, and java.text to use switch expressions

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4182/head:pull/4182
$ git checkout pull/4182

Update a local copy of the PR:
$ git checkout pull/4182
$ git pull https://git.openjdk.java.net/jdk pull/4182/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4182

View PR using the GUI difftool:
$ git pr show -t 4182

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4182.diff

@bridgekeeper
Copy link

bridgekeeper bot commented May 25, 2021

👋 Welcome back pconcannon! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label May 25, 2021
@openjdk
Copy link

openjdk bot commented May 25, 2021

@pconcannon The following labels will be automatically applied to this pull request:

  • core-libs
  • i18n

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org labels May 25, 2021
@mlbridge
Copy link

mlbridge bot commented May 25, 2021

@mlbridge
Copy link

mlbridge bot commented May 25, 2021

Mailing list message from Brian Goetz on core-libs-dev:

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.

Copy link
Member

@jddarcy jddarcy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in java.math look fine.

@openjdk
Copy link

openjdk bot commented May 25, 2021

@pconcannon This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8267670: Update java.io, java.math, and java.text to use switch expressions

Reviewed-by: darcy, chegar, naoto, iris, dfuchs, lancea, vtewari

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 25, 2021
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 25, 2021
@openjdk openjdk bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 26, 2021
@pconcannon
Copy link
Contributor Author

Mailing list message from Brian Goetz on core-libs-dev:

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

Copy link
Contributor

@LanceAndersen LanceAndersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good Patrick

@pconcannon
Copy link
Contributor Author

/integrate

@openjdk openjdk bot closed this Jun 1, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 1, 2021
@openjdk
Copy link

openjdk bot commented Jun 1, 2021

@pconcannon Since your change was applied there has been 1 commit pushed to the master branch:

  • f5634fe: 8267979: C2: Fix verification code in SubTypeCheckNode::Ideal()

Your commit was automatically rebased without conflicts.

Pushed as commit 4eb2168.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@pconcannon pconcannon deleted the JDK-8267670 branch July 6, 2021 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org i18n i18n-dev@openjdk.org integrated Pull request has been integrated
8 participants