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
8275771: JDK source code contains redundant boolean operations in jdk.compiler and langtools #6599
8275771: JDK source code contains redundant boolean operations in jdk.compiler and langtools #6599
Conversation
….compiler and langtools
|
@vicente-romero-oracle The following labels will be automatically applied to this pull request:
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. |
Webrevs
|
@@ -1313,9 +1313,9 @@ public void visitConditional(JCConditional tree) { | |||
@Override | |||
public void visitReference(JCMemberReference tree) { | |||
if (sRet.hasTag(VOID)) { | |||
result &= true; | |||
result = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the equivalent statement to
result &= true
just
result
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreeing with jddarcy:
a & true === a
so current code just keeps the value of result
while the new one sets result
to true
.
@@ -183,7 +183,7 @@ private boolean parseOptions(String args[]) { | |||
log.error("cannot close " + filename, e); | |||
} | |||
} | |||
if ( ok = true && contents != null ) { | |||
if ( ok && contents != null ) { | |||
String tokens[] = (new String(contents)).split("\\s+"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the intended composite predicate here is thought to be
ok == true && contents != null
which is equivalent to
ok && contents != null.
The semantics of the current code are equivalent to just
contents != null
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The semantics is definitely changed (considering the first branch was always true originally) but it may be the original implementation being incorrect,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well not assigning true
to ok
also breaks the semantics as ok
is used in boolean expressions below this point. So if we want to keep the semantics 100% we will have to either let the code as it was or do:
ok = true;
if (contents != null) {
...
@@ -1313,9 +1313,9 @@ public void visitConditional(JCConditional tree) { | |||
@Override | |||
public void visitReference(JCMemberReference tree) { | |||
if (sRet.hasTag(VOID)) { | |||
result &= true; | |||
result = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreeing with jddarcy:
a & true === a
so current code just keeps the value of result
while the new one sets result
to true
.
@@ -1335,9 +1335,9 @@ public void visitParens(JCParens tree) { | |||
@Override | |||
public void visitLambda(JCLambda tree) { | |||
if (sRet.hasTag(VOID)) { | |||
result &= true; | |||
result = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, the change is changing the semantics:
original code keeps the value of result
while the new one sets it to true
.
@@ -183,7 +183,7 @@ private boolean parseOptions(String args[]) { | |||
log.error("cannot close " + filename, e); | |||
} | |||
} | |||
if ( ok = true && contents != null ) { | |||
if ( ok && contents != null ) { | |||
String tokens[] = (new String(contents)).split("\\s+"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The semantics is definitely changed (considering the first branch was always true originally) but it may be the original implementation being incorrect,
/label remove build |
@magicus |
submitted another iteration to the PR, thanks for the comment so far |
@vicente-romero-oracle This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
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 320 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
|
thanks Jan for the approval :) I will wait a bit for the other reviewers |
/integrate |
Going to push as commit 3c2951f.
Your commit was automatically rebased without conflicts. |
@vicente-romero-oracle Pushed as commit 3c2951f. |
Hi,
Please review this PR which is basically rewriting some redundant boolean expressions in the compiler.
TIA
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/6599/head:pull/6599
$ git checkout pull/6599
Update a local copy of the PR:
$ git checkout pull/6599
$ git pull https://git.openjdk.java.net/jdk pull/6599/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 6599
View PR using the GUI difftool:
$ git pr show -t 6599
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/6599.diff