New lint: replace iter.filter(x).count() > 0
with iter.any(x)
#5932
Labels
A-lint
Area: New lints
L-complexity
Lint: Belongs in the complexity lint group
S-needs-discussion
Status: Needs further discussion before merging or work can be started
What it does
It suggests replacing
iter.filter(x).count() > 0
withiter.any(x)
. The suggestion should beMachineApplicable
.Categories (optional)
What is the advantage of the recommended code over the original code
It's more concise and it should be faster since
any
is allowed to return early whilefilter().count()
has to walk through all items.Drawbacks
None.
Example
Could be written as:
The text was updated successfully, but these errors were encountered: