From dc1fb37eb4f7cce02d1df70c88124df37e8f7963 Mon Sep 17 00:00:00 2001 From: Cameron McHenry Date: Wed, 9 Oct 2024 17:20:43 -0400 Subject: [PATCH] perf(linter): use `CompactStr` in `no-console` --- crates/oxc_linter/src/rules/eslint/no_console.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/crates/oxc_linter/src/rules/eslint/no_console.rs b/crates/oxc_linter/src/rules/eslint/no_console.rs index 5bf03d311fa920..4a757fdcccba58 100644 --- a/crates/oxc_linter/src/rules/eslint/no_console.rs +++ b/crates/oxc_linter/src/rules/eslint/no_console.rs @@ -1,7 +1,7 @@ use oxc_ast::{ast::Expression, AstKind}; use oxc_diagnostics::OxcDiagnostic; use oxc_macros::declare_oxc_lint; -use oxc_span::Span; +use oxc_span::{CompactStr, Span}; use crate::{context::LintContext, rule::Rule, AstNode}; @@ -21,7 +21,7 @@ pub struct NoConsoleConfig { /// console.log('foo'); // will error /// console.info('bar'); // will not error /// ``` - pub allow: Vec, + pub allow: Vec, } impl std::ops::Deref for NoConsole { @@ -58,10 +58,7 @@ impl Rule for NoConsole { .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(), }))