mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
perf(linter): use CompactStr in no-large-snapshots (#6402)
This commit is contained in:
parent
c382ec4f32
commit
9906849b33
1 changed files with 7 additions and 9 deletions
|
|
@ -6,7 +6,7 @@ use oxc_ast::{
|
||||||
};
|
};
|
||||||
use oxc_diagnostics::OxcDiagnostic;
|
use oxc_diagnostics::OxcDiagnostic;
|
||||||
use oxc_macros::declare_oxc_lint;
|
use oxc_macros::declare_oxc_lint;
|
||||||
use oxc_span::{GetSpan, Span};
|
use oxc_span::{CompactStr, GetSpan, Span};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ pub struct NoLargeSnapshots(Box<NoLargeSnapshotsConfig>);
|
||||||
pub struct NoLargeSnapshotsConfig {
|
pub struct NoLargeSnapshotsConfig {
|
||||||
pub max_size: usize,
|
pub max_size: usize,
|
||||||
pub inline_max_size: usize,
|
pub inline_max_size: usize,
|
||||||
pub allowed_snapshots: FxHashMap<String, Vec<String>>,
|
pub allowed_snapshots: FxHashMap<CompactStr, Vec<CompactStr>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Deref for NoLargeSnapshots {
|
impl Deref for NoLargeSnapshots {
|
||||||
|
|
@ -281,21 +281,19 @@ impl NoLargeSnapshots {
|
||||||
#[allow(clippy::unnecessary_wraps)]
|
#[allow(clippy::unnecessary_wraps)]
|
||||||
pub fn compile_allowed_snapshots(
|
pub fn compile_allowed_snapshots(
|
||||||
matchers: &serde_json::Map<String, serde_json::Value>,
|
matchers: &serde_json::Map<String, serde_json::Value>,
|
||||||
) -> Option<FxHashMap<String, Vec<String>>> {
|
) -> Option<FxHashMap<CompactStr, Vec<CompactStr>>> {
|
||||||
Some(
|
Some(
|
||||||
matchers
|
matchers
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(key, value)| {
|
.map(|(key, value)| {
|
||||||
let serde_json::Value::Array(configs) = value else {
|
let serde_json::Value::Array(configs) = value else {
|
||||||
return (String::from(key), vec![]);
|
return (CompactStr::from(key.as_str()), vec![]);
|
||||||
};
|
};
|
||||||
|
|
||||||
let configs = configs
|
let configs =
|
||||||
.iter()
|
configs.iter().filter_map(|c| c.as_str().map(CompactStr::from)).collect();
|
||||||
.filter_map(|c| c.as_str().map(std::string::ToString::to_string))
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
(String::from(key), configs)
|
(CompactStr::from(key.as_str()), configs)
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue