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

[Trivial] Use Length check instead of Any() for clarity and efficiency #12292

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

yahiheb
Copy link
Collaborator

@yahiheb yahiheb commented Jan 21, 2024

https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1860

To determine whether a collection type has any elements, it's more efficient and clearer to use the Length, Count, or IsEmpty (if possible) properties than to call the Enumerable.Any method.

Any(), which is an extension method, uses language integrated query (LINQ). It's more efficient to rely on the collection's own properties, and it also clarifies intent.

Copy link
Collaborator

@kiminuo kiminuo left a comment

Choose a reason for hiding this comment

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

LGTM

@kiminuo kiminuo merged commit 9971d02 into WalletWasabi:master Jan 22, 2024
7 checks passed
@yahiheb yahiheb deleted the CA1860-warnings-fix branch January 22, 2024 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants