Skip to content

Commit

Permalink
perf(linter): use CompactStr in no-bitwise (#6398)
Browse files Browse the repository at this point in the history
  • Loading branch information
camchenry committed Oct 10, 2024
1 parent 84aa2a2 commit f5f00a1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions crates/oxc_linter/src/rules/eslint/no_bitwise.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use oxc_span::{CompactStr, Span};
use oxc_syntax::operator::BinaryOperator;

use crate::{context::LintContext, rule::Rule, AstNode};
Expand All @@ -17,7 +17,7 @@ pub struct NoBitwise(Box<NoBitwiseConfig>);

#[derive(Debug, Default, Clone)]
pub struct NoBitwiseConfig {
allow: Vec<String>,
allow: Vec<CompactStr>,
int32_hint: bool,
}

Expand Down Expand Up @@ -57,10 +57,7 @@ impl Rule for NoBitwise {
.and_then(|v| v.get("allow"))
.and_then(serde_json::Value::as_array)
.map(|v| {
v.iter()
.filter_map(serde_json::Value::as_str)
.map(ToString::to_string)
.collect()
v.iter().filter_map(serde_json::Value::as_str).map(CompactStr::from).collect()
})
.unwrap_or_default(),
int32_hint: obj
Expand Down Expand Up @@ -107,7 +104,7 @@ impl Rule for NoBitwise {
}
}

fn allowed_operator(allow: &[String], operator: &str) -> bool {
fn allowed_operator(allow: &[CompactStr], operator: &str) -> bool {
allow.iter().any(|s| s == operator)
}

Expand Down

0 comments on commit f5f00a1

Please sign in to comment.