Skip to content

Commit

Permalink
Use iter instead of manual loop
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser committed Apr 16, 2024
1 parent bac6d21 commit e94a8ee
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/checkers/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ impl<'a> Checker<'a> {

/// Returns whether any of the given rules should be checked.
#[inline]
pub(crate) const fn any_enabled(&self, rules: &[Rule]) -> bool {
pub(crate) fn any_enabled(&self, rules: &[Rule]) -> bool {
self.settings.rules.any_enabled(rules)
}

Expand Down
12 changes: 2 additions & 10 deletions crates/ruff_linter/src/registry/rule_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,16 +246,8 @@ impl RuleSet {

/// Returns `true` if any of the rules in `rules` are in this set.
#[inline]
pub const fn any(&self, rules: &[Rule]) -> bool {
let mut any = false;
let mut i = 0;

while i < rules.len() {
any |= self.contains(rules[i]);
i += 1;
}

any
pub fn any(&self, rules: &[Rule]) -> bool {
rules.iter().any(|rule| self.contains(*rule))
}

/// Returns an iterator over the rules in this set.
Expand Down
2 changes: 1 addition & 1 deletion crates/ruff_linter/src/settings/rule_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl RuleTable {

/// Returns whether any of the given rules should be checked.
#[inline]
pub const fn any_enabled(&self, rules: &[Rule]) -> bool {
pub fn any_enabled(&self, rules: &[Rule]) -> bool {
self.enabled.any(rules)
}

Expand Down

0 comments on commit e94a8ee

Please sign in to comment.