perf(linter): use FxDashMap for module cache (#7522)

Same as #7521. Use `FxDashMap` instead of plain `DashMap` for module cache.
This commit is contained in:
overlookmotel 2024-11-28 12:32:43 +00:00
parent 4a98230f07
commit 6655345bb9

View file

@ -5,9 +5,11 @@ use std::{
use dashmap::{mapref::one::Ref, DashMap}; use dashmap::{mapref::one::Ref, DashMap};
use oxc_semantic::ModuleRecord; use oxc_semantic::ModuleRecord;
use rustc_hash::FxHashMap; use rustc_hash::{FxBuildHasher, FxHashMap};
use std::num::NonZeroUsize; use std::num::NonZeroUsize;
type FxDashMap<K, V> = DashMap<K, V, FxBuildHasher>;
/// `CacheState` and `CacheStateEntry` are used to fix the problem where /// `CacheState` and `CacheStateEntry` are used to fix the problem where
/// there is a brief moment when a concurrent fetch can miss the cache. /// there is a brief moment when a concurrent fetch can miss the cache.
/// ///
@ -26,7 +28,7 @@ enum CacheStateEntry {
} }
/// Keyed by canonicalized path /// Keyed by canonicalized path
type ModuleMap = DashMap<Box<Path>, ModuleState>; type ModuleMap = FxDashMap<Box<Path>, ModuleState>;
#[derive(Clone)] #[derive(Clone)]
pub(super) enum ModuleState { pub(super) enum ModuleState {