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

Optimize temporary variable creation by excluding void method calls; … #6569

Merged
merged 4 commits into from
May 3, 2024

Conversation

iamsanjaymalakar
Copy link
Member

fixes #6568.

if (node instanceof MethodInvocationNode) {
MethodInvocationTree methodInvocationTree = (MethodInvocationTree) node.getTree();
ExecutableElement executableElement = TreeUtils.elementFromUse(methodInvocationTree);
if (ElementUtils.getType(executableElement).getKind() == TypeKind.VOID) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you test that the type of the element is void in these cases? I would have thought we would need to write some code to get the return type and check that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't added any new test case to check that. Checked using the existing test cases. I'll add a new test case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind, I looked at this similar code and it is doing the same check so this is fine.

Adding a test for this directly will be hard since it would depend on the temporary variable names or something like that. I don't think it's necessary as long as extant tests are passing.

msridhar
msridhar previously approved these changes May 2, 2024
Copy link
Contributor

@msridhar msridhar left a comment

Choose a reason for hiding this comment

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

@msridhar msridhar enabled auto-merge (squash) May 2, 2024 18:30
@msridhar msridhar merged commit 5b123d5 into master May 3, 2024
28 checks passed
@msridhar msridhar deleted the 6568-dev branch May 3, 2024 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize temporary variable creation by excluding void method invocations in ResourceLeakTransfer
2 participants