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

Use isEmpty instead of 0 comparisons #3999

Merged
merged 1 commit into from
Jan 2, 2024
Merged

Conversation

wborn
Copy link
Member

@wborn wborn commented Jan 2, 2024

isEmpty() expresses the intent more clearly and is therefore preferred. Counting the number of elements can also be an expensive operation e.g. when using linked lists.

`isEmpty()` expresses the intent more clearly and is therefore preferred.
Counting the number of elements can also be an expensive operation e.g. when using linked lists.

Signed-off-by: Wouter Born <github@maindrain.net>
@wborn wborn requested a review from a team as a code owner January 2, 2024 17:13
Copy link
Member

@J-N-K J-N-K left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@J-N-K J-N-K added the enhancement An enhancement or new feature of the Core label Jan 2, 2024
@J-N-K J-N-K added this to the 4.2 milestone Jan 2, 2024
@J-N-K J-N-K merged commit 89b67ad into openhab:main Jan 2, 2024
3 checks passed
@wborn wborn deleted the use-isempty branch January 2, 2024 17:49
cipianpascu pushed a commit to cipianpascu/openhab-core that referenced this pull request Jan 17, 2024
`isEmpty()` expresses the intent more clearly and is therefore preferred.
Counting the number of elements can also be an expensive operation e.g. when using linked lists.

Signed-off-by: Wouter Born <github@maindrain.net>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature of the Core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants