Skip to content

Remove null checks from instanceof checks. #1326

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

Conversation

hduelme
Copy link
Contributor

@hduelme hduelme commented Jan 26, 2023

In Java an instanceof check always includes an null check. So there is no need for an explicit null check.

@gregturn gregturn self-assigned this Feb 6, 2023
@gregturn gregturn added the type: enhancement A general enhancement label Feb 6, 2023
@gregturn gregturn added this to the 4.0.2 milestone Feb 6, 2023
@gregturn gregturn changed the title remove null checks from instanceof checks Remove null checks from instanceof checks. Feb 6, 2023
@gregturn gregturn closed this in a7a2726 Feb 6, 2023
gregturn added a commit that referenced this pull request Feb 6, 2023
All of these instanceof checks can also take advantage of Java 17's pattern matching instanceof operator.

Related: #1326.
@gregturn
Copy link
Contributor

gregturn commented Feb 6, 2023

Thanks @hduelme!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants