Skip to content

Use Collection#isEmpty() instead of comparing size() #2305

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

greg-at-moderne
Copy link
Contributor

What:
Changing calls to Collections.size() == 0 to Collection.isEmpty().

Why:
This is more readable and likely also more efficient.

How:
This has been generated using OpenRewrite's https://docs.openrewrite.org/recipes/staticanalysis/isemptycalloncollections

@greg-at-moderne greg-at-moderne force-pushed the refactor/use-collection-is-empty-instead-of-comparing-size branch from ed918e8 to c67efe4 Compare April 15, 2025 05:48
odrotbohm pushed a commit that referenced this pull request Aug 12, 2025
@odrotbohm odrotbohm self-assigned this Aug 12, 2025
@odrotbohm odrotbohm added type: enhancement in: core Core parts of the project labels Aug 12, 2025
@odrotbohm odrotbohm added this to the 3.0.0-M4 milestone Aug 12, 2025
@odrotbohm
Copy link
Member

That's merged, thanks!

@odrotbohm odrotbohm closed this Aug 12, 2025
@odrotbohm odrotbohm changed the title refactor: Use Collection#isEmpty() instead of comparing size() Use Collection#isEmpty() instead of comparing size() Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Core parts of the project type: polish
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants