mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 13:51:19 +03:00
refactor: Use ahash
from swc_common
in more places (#7815)
**Description:** Uses ahash from swc_common in more places. This allows for more easily swapping out ahash with rustc_hash.
This commit is contained in:
parent
2dc88ef147
commit
b43e38d3f9
14
Cargo.lock
generated
14
Cargo.lock
generated
@ -3527,7 +3527,6 @@ dependencies = [
|
||||
name = "swc"
|
||||
version = "0.264.57"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"ansi_term",
|
||||
"anyhow",
|
||||
"base64 0.13.1",
|
||||
@ -3598,7 +3597,6 @@ dependencies = [
|
||||
name = "swc_bundler"
|
||||
version = "0.217.48"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"anyhow",
|
||||
"crc",
|
||||
"dashmap",
|
||||
@ -4026,7 +4024,6 @@ dependencies = [
|
||||
name = "swc_ecma_lints"
|
||||
version = "0.85.21"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"auto_impl",
|
||||
"dashmap",
|
||||
"parking_lot",
|
||||
@ -4049,7 +4046,6 @@ dependencies = [
|
||||
name = "swc_ecma_loader"
|
||||
version = "0.43.21"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"anyhow",
|
||||
"dashmap",
|
||||
"lazy_static",
|
||||
@ -4070,7 +4066,6 @@ dependencies = [
|
||||
name = "swc_ecma_minifier"
|
||||
version = "0.184.48"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"ansi_term",
|
||||
"anyhow",
|
||||
"arrayvec",
|
||||
@ -4138,7 +4133,6 @@ dependencies = [
|
||||
name = "swc_ecma_preset_env"
|
||||
version = "0.198.37"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"anyhow",
|
||||
"criterion",
|
||||
"dashmap",
|
||||
@ -4269,7 +4263,6 @@ dependencies = [
|
||||
name = "swc_ecma_transforms_compat"
|
||||
version = "0.156.28"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"arrayvec",
|
||||
"indexmap",
|
||||
"is-macro",
|
||||
@ -4310,7 +4303,6 @@ name = "swc_ecma_transforms_module"
|
||||
version = "0.173.33"
|
||||
dependencies = [
|
||||
"Inflector",
|
||||
"ahash 0.8.3",
|
||||
"anyhow",
|
||||
"bitflags 2.3.2",
|
||||
"indexmap",
|
||||
@ -4339,7 +4331,6 @@ dependencies = [
|
||||
name = "swc_ecma_transforms_optimization"
|
||||
version = "0.190.35"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"dashmap",
|
||||
"indexmap",
|
||||
"once_cell",
|
||||
@ -4394,7 +4385,6 @@ dependencies = [
|
||||
name = "swc_ecma_transforms_react"
|
||||
version = "0.176.33"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"base64 0.13.1",
|
||||
"dashmap",
|
||||
"indexmap",
|
||||
@ -4468,7 +4458,6 @@ dependencies = [
|
||||
name = "swc_ecma_usage_analyzer"
|
||||
version = "0.16.20"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"indexmap",
|
||||
"rustc-hash",
|
||||
"swc_atoms",
|
||||
@ -4600,9 +4589,9 @@ dependencies = [
|
||||
name = "swc_graph_analyzer"
|
||||
version = "0.20.22"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"auto_impl",
|
||||
"petgraph",
|
||||
"swc_common",
|
||||
"swc_fast_graph",
|
||||
"testing",
|
||||
"tracing",
|
||||
@ -4778,7 +4767,6 @@ dependencies = [
|
||||
name = "swc_node_comments"
|
||||
version = "0.18.19"
|
||||
dependencies = [
|
||||
"ahash 0.8.3",
|
||||
"dashmap",
|
||||
"swc_atoms",
|
||||
"swc_common",
|
||||
|
@ -48,7 +48,6 @@ plugin_transform_host_native = [
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8.3"
|
||||
anyhow = "1"
|
||||
base64 = "0.13.0"
|
||||
dashmap = "5.4.0"
|
||||
|
@ -24,7 +24,7 @@ use swc_atoms::JsWord;
|
||||
use swc_cached::regex::CachedRegex;
|
||||
use swc_common::{
|
||||
chain,
|
||||
collections::{AHashMap, AHashSet},
|
||||
collections::{AHashMap, AHashSet, ARandomState},
|
||||
comments::{Comments, SingleThreadedComments},
|
||||
errors::Handler,
|
||||
plugin::metadata::TransformPluginMetadataContext,
|
||||
@ -1497,7 +1497,7 @@ impl Default for ErrorFormat {
|
||||
}
|
||||
|
||||
/// `paths` section of `tsconfig.json`.
|
||||
pub type Paths = IndexMap<String, Vec<String>, ahash::RandomState>;
|
||||
pub type Paths = IndexMap<String, Vec<String>, ARandomState>;
|
||||
pub(crate) type CompiledPaths = Vec<(String, Vec<String>)>;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@ -1746,7 +1746,7 @@ pub struct ErrorConfig {
|
||||
#[serde(deny_unknown_fields, rename_all = "camelCase")]
|
||||
pub struct GlobalPassOption {
|
||||
#[serde(default)]
|
||||
pub vars: IndexMap<JsWord, JsWord, ahash::RandomState>,
|
||||
pub vars: IndexMap<JsWord, JsWord, ARandomState>,
|
||||
#[serde(default)]
|
||||
pub envs: GlobalInliningPassEnvs,
|
||||
|
||||
@ -1826,7 +1826,7 @@ impl GlobalPassOption {
|
||||
} else {
|
||||
match &self.envs {
|
||||
GlobalInliningPassEnvs::List(env_list) => {
|
||||
static CACHE: Lazy<DashMap<Vec<String>, ValuesMap, ahash::RandomState>> =
|
||||
static CACHE: Lazy<DashMap<Vec<String>, ValuesMap, ARandomState>> =
|
||||
Lazy::new(Default::default);
|
||||
|
||||
let cache_key = env_list.iter().cloned().collect::<Vec<_>>();
|
||||
@ -1847,9 +1847,8 @@ impl GlobalPassOption {
|
||||
}
|
||||
|
||||
GlobalInliningPassEnvs::Map(map) => {
|
||||
static CACHE: Lazy<
|
||||
DashMap<Vec<(JsWord, JsWord)>, ValuesMap, ahash::RandomState>,
|
||||
> = Lazy::new(Default::default);
|
||||
static CACHE: Lazy<DashMap<Vec<(JsWord, JsWord)>, ValuesMap, ARandomState>> =
|
||||
Lazy::new(Default::default);
|
||||
|
||||
let cache_key = self
|
||||
.vars
|
||||
@ -1873,7 +1872,7 @@ impl GlobalPassOption {
|
||||
};
|
||||
|
||||
let global_exprs = {
|
||||
static CACHE: Lazy<DashMap<Vec<(JsWord, JsWord)>, GlobalExprMap, ahash::RandomState>> =
|
||||
static CACHE: Lazy<DashMap<Vec<(JsWord, JsWord)>, GlobalExprMap, ARandomState>> =
|
||||
Lazy::new(Default::default);
|
||||
|
||||
let cache_key = self
|
||||
@ -1904,7 +1903,7 @@ impl GlobalPassOption {
|
||||
};
|
||||
|
||||
let global_map = {
|
||||
static CACHE: Lazy<DashMap<Vec<(JsWord, JsWord)>, ValuesMap, ahash::RandomState>> =
|
||||
static CACHE: Lazy<DashMap<Vec<(JsWord, JsWord)>, ValuesMap, ARandomState>> =
|
||||
Lazy::new(Default::default);
|
||||
|
||||
let cache_key = self
|
||||
@ -1943,7 +1942,7 @@ fn default_env_name() -> String {
|
||||
}
|
||||
|
||||
fn build_resolver(base_url: PathBuf, paths: CompiledPaths) -> Box<SwcImportResolver> {
|
||||
static CACHE: Lazy<DashMap<(PathBuf, CompiledPaths), SwcImportResolver, ahash::RandomState>> =
|
||||
static CACHE: Lazy<DashMap<(PathBuf, CompiledPaths), SwcImportResolver, ARandomState>> =
|
||||
Lazy::new(Default::default);
|
||||
|
||||
if let Some(cached) = CACHE.get(&(base_url.clone(), paths.clone())) {
|
||||
|
@ -24,7 +24,6 @@ concurrent = ["swc_common/concurrent", "dashmap", "rayon", "indexmap/rayon"]
|
||||
default = []
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8"
|
||||
anyhow = "1"
|
||||
crc = "2.1.0"
|
||||
dashmap = { version = "5.4.0", optional = true }
|
||||
|
@ -5,7 +5,7 @@ use indexmap::IndexSet;
|
||||
use petgraph::EdgeDirection;
|
||||
use swc_atoms::js_word;
|
||||
use swc_common::{
|
||||
collections::{AHashMap, AHashSet},
|
||||
collections::{AHashMap, AHashSet, ARandomState},
|
||||
sync::Lock,
|
||||
FileName, SyntaxContext, DUMMY_SP,
|
||||
};
|
||||
@ -138,7 +138,7 @@ where
|
||||
graph: &ModuleGraph,
|
||||
start: ModuleId,
|
||||
dejavu: &mut AHashSet<ModuleId>,
|
||||
) -> IndexSet<ModuleId, ahash::RandomState> {
|
||||
) -> IndexSet<ModuleId, ARandomState> {
|
||||
let mut set = IndexSet::default();
|
||||
|
||||
for dep in graph.neighbors_directed(start, Outgoing) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use indexmap::IndexMap;
|
||||
use swc_atoms::{js_word, JsWord};
|
||||
use swc_common::{FileName, SyntaxContext};
|
||||
use swc_common::{collections::ARandomState, FileName, SyntaxContext};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_utils::find_pat_ids;
|
||||
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
|
||||
@ -42,7 +42,7 @@ where
|
||||
#[derive(Debug, Default)]
|
||||
pub(super) struct RawExports {
|
||||
/// Key is None if it's exported from the module itself.
|
||||
pub items: IndexMap<Option<Str>, Vec<Specifier>, ahash::RandomState>,
|
||||
pub items: IndexMap<Option<Str>, Vec<Specifier>, ARandomState>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
@ -1,10 +1,9 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use ahash::AHashMap;
|
||||
use anyhow::Error;
|
||||
use relative_path::RelativePath;
|
||||
use swc_atoms::js_word;
|
||||
use swc_common::{util::move_map::MoveMap, FileName, Mark, DUMMY_SP};
|
||||
use swc_common::{collections::AHashMap, util::move_map::MoveMap, FileName, Mark, DUMMY_SP};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_transforms_base::{
|
||||
fixer::fixer,
|
||||
|
@ -3,7 +3,7 @@ use std::path::PathBuf;
|
||||
|
||||
use anyhow::Error;
|
||||
use indexmap::IndexMap;
|
||||
use swc_common::{sync::Lrc, FileName, SourceMap, Span, GLOBALS};
|
||||
use swc_common::{collections::ARandomState, sync::Lrc, FileName, SourceMap, Span, GLOBALS};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_parser::{lexer::Lexer, Parser, StringInput};
|
||||
use swc_ecma_utils::drop_span;
|
||||
@ -19,7 +19,7 @@ pub(crate) struct Tester<'a> {
|
||||
|
||||
pub struct Loader {
|
||||
cm: Lrc<SourceMap>,
|
||||
files: IndexMap<String, String, ahash::RandomState>,
|
||||
files: IndexMap<String, String, ARandomState>,
|
||||
}
|
||||
|
||||
impl Load for Loader {
|
||||
@ -108,7 +108,7 @@ pub(crate) fn suite() -> TestBuilder {
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct TestBuilder {
|
||||
files: IndexMap<String, String, ahash::RandomState>,
|
||||
files: IndexMap<String, String, ARandomState>,
|
||||
}
|
||||
|
||||
impl TestBuilder {
|
||||
|
@ -2,7 +2,11 @@ use std::{collections::VecDeque, iter::from_fn, mem::take, time::Instant};
|
||||
|
||||
use indexmap::IndexSet;
|
||||
use petgraph::EdgeDirection::Outgoing;
|
||||
use swc_common::{collections::AHashSet, sync::Lrc, SourceMap, SyntaxContext};
|
||||
use swc_common::{
|
||||
collections::{AHashSet, ARandomState},
|
||||
sync::Lrc,
|
||||
SourceMap, SyntaxContext,
|
||||
};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_utils::prepend_stmts;
|
||||
|
||||
@ -133,7 +137,7 @@ fn cycles_for(
|
||||
cycles: &[Vec<ModuleId>],
|
||||
id: ModuleId,
|
||||
checked: &mut Vec<ModuleId>,
|
||||
) -> IndexSet<ModuleId, ahash::RandomState> {
|
||||
) -> IndexSet<ModuleId, ARandomState> {
|
||||
checked.push(id);
|
||||
let mut v = cycles
|
||||
.iter()
|
||||
|
@ -4,7 +4,7 @@ use indexmap::IndexSet;
|
||||
use petgraph::EdgeDirection::{Incoming as Dependants, Outgoing as Dependencies};
|
||||
use swc_atoms::js_word;
|
||||
use swc_common::{
|
||||
collections::{AHashMap, AHashSet},
|
||||
collections::{AHashMap, AHashSet, ARandomState},
|
||||
sync::Lrc,
|
||||
util::take::Take,
|
||||
SourceMap, Spanned, SyntaxContext,
|
||||
@ -501,11 +501,11 @@ impl Visit for InitializerFinder {
|
||||
/// But we care about modifications.
|
||||
#[derive(Default)]
|
||||
struct RequirementCalculator {
|
||||
required_ids: IndexSet<(Id, Required), ahash::RandomState>,
|
||||
required_ids: IndexSet<(Id, Required), ARandomState>,
|
||||
/// While bundling, there can be two bindings with same name and syntax
|
||||
/// context, in case of wrapped es modules. We exclude them from dependency
|
||||
/// graph.
|
||||
excluded: IndexSet<Id, ahash::RandomState>,
|
||||
excluded: IndexSet<Id, ARandomState>,
|
||||
|
||||
in_weak: bool,
|
||||
in_var_decl: bool,
|
||||
|
@ -101,7 +101,7 @@ where
|
||||
V: Clone,
|
||||
{
|
||||
#[cfg(feature = "concurrent")]
|
||||
inner: dashmap::DashMap<K, V, ahash::RandomState>,
|
||||
inner: dashmap::DashMap<K, V, swc_common::collections::ARandomState>,
|
||||
#[cfg(not(feature = "concurrent"))]
|
||||
inner: std::cell::RefCell<swc_common::collections::AHashMap<K, V>>,
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ concurrent = ["parking_lot"]
|
||||
debug = []
|
||||
default = []
|
||||
diagnostic-serde = []
|
||||
perf = ["parking_lot"]
|
||||
perf = []
|
||||
plugin-base = ["__plugin", "anyhow", "rkyv-impl", "diagnostic-serde"]
|
||||
plugin-mode = ["__plugin_mode", "plugin-base"]
|
||||
plugin-rt = ["__plugin_rt", "plugin-base"]
|
||||
|
@ -12,16 +12,20 @@ mod fxhash {
|
||||
|
||||
use rustc_hash::FxHasher;
|
||||
|
||||
pub type AHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;
|
||||
pub type ARandomState = BuildHasherDefault<FxHasher>;
|
||||
|
||||
pub type AHashSet<V> = HashSet<V, BuildHasherDefault<FxHasher>>;
|
||||
pub type AHashMap<K, V> = HashMap<K, V, ARandomState>;
|
||||
|
||||
pub type AHashSet<V> = HashSet<V, ARandomState>;
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "perf"))]
|
||||
mod ahash {
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
pub type AHashMap<K, V> = HashMap<K, V, ahash::RandomState>;
|
||||
pub type ARandomState = ahash::RandomState;
|
||||
|
||||
pub type AHashSet<V> = HashSet<V, ahash::RandomState>;
|
||||
pub type AHashMap<K, V> = HashMap<K, V, ARandomState>;
|
||||
|
||||
pub type AHashSet<V> = HashSet<V, ARandomState>;
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ version = "0.85.21"
|
||||
bench = false
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8"
|
||||
auto_impl = "1.1.0"
|
||||
dashmap = "5.4.0"
|
||||
parking_lot = "0.12.1"
|
||||
|
@ -1,7 +1,7 @@
|
||||
use dashmap::DashMap;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use swc_common::{errors::HANDLER, sync::Lazy, Span};
|
||||
use swc_common::{collections::ARandomState, errors::HANDLER, sync::Lazy, Span};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
|
||||
|
||||
@ -76,7 +76,7 @@ impl DotNotation {
|
||||
}
|
||||
|
||||
if let Some(pattern) = &self.pattern {
|
||||
static REGEX_CACHE: Lazy<DashMap<String, Regex, ahash::RandomState>> =
|
||||
static REGEX_CACHE: Lazy<DashMap<String, Regex, ARandomState>> =
|
||||
Lazy::new(Default::default);
|
||||
|
||||
if !REGEX_CACHE.contains_key(pattern) {
|
||||
|
@ -2,7 +2,7 @@ use dashmap::DashMap;
|
||||
use regex::Regex;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use swc_common::{
|
||||
collections::{AHashMap, AHashSet},
|
||||
collections::{AHashMap, AHashSet, ARandomState},
|
||||
errors::HANDLER,
|
||||
sync::Lazy,
|
||||
Span,
|
||||
@ -121,7 +121,7 @@ impl NoParamReassign {
|
||||
}
|
||||
|
||||
if let Some(ignore_names_patterns) = &self.ignore_names_patterns {
|
||||
static REGEX_CACHE: Lazy<DashMap<String, Regex, ahash::RandomState>> =
|
||||
static REGEX_CACHE: Lazy<DashMap<String, Regex, ARandomState>> =
|
||||
Lazy::new(Default::default);
|
||||
|
||||
let sym = &*ident.sym;
|
||||
|
@ -25,7 +25,6 @@ node = ["normpath", "serde_json", "dashmap", "once_cell", "path-clean"]
|
||||
tsc = ["dashmap", "once_cell", "swc_cached"]
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8.3"
|
||||
anyhow = "1.0.71"
|
||||
dashmap = { version = "5.4.0", optional = true }
|
||||
lru = { version = "0.10.0", optional = true }
|
||||
|
@ -18,7 +18,7 @@ use path_clean::PathClean;
|
||||
use pathdiff::diff_paths;
|
||||
use serde::Deserialize;
|
||||
use swc_common::{
|
||||
collections::{AHashMap, AHashSet},
|
||||
collections::{AHashMap, AHashSet, ARandomState},
|
||||
FileName,
|
||||
};
|
||||
use tracing::{debug, trace, Level};
|
||||
@ -33,7 +33,7 @@ static PACKAGE: &str = "package.json";
|
||||
/// directory containing the package.json file which is important
|
||||
/// to ensure we only apply these `browser` rules to modules in
|
||||
/// the owning package.
|
||||
static BROWSER_CACHE: Lazy<DashMap<PathBuf, BrowserCache, ahash::RandomState>> =
|
||||
static BROWSER_CACHE: Lazy<DashMap<PathBuf, BrowserCache, ARandomState>> =
|
||||
Lazy::new(Default::default);
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
|
@ -33,7 +33,6 @@ serde-impl = []
|
||||
trace-ast = []
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8.3"
|
||||
arrayvec = "0.7.2"
|
||||
backtrace = { version = "0.3.61", optional = true }
|
||||
indexmap = "1.9.3"
|
||||
|
@ -7,7 +7,7 @@ use indexmap::IndexSet;
|
||||
use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
|
||||
use swc_atoms::JsWord;
|
||||
use swc_common::{
|
||||
collections::{AHashMap, AHashSet},
|
||||
collections::{AHashMap, AHashSet, ARandomState},
|
||||
SyntaxContext,
|
||||
};
|
||||
use swc_ecma_ast::*;
|
||||
@ -38,7 +38,7 @@ pub(crate) struct ProgramData {
|
||||
|
||||
pub(crate) scopes: FxHashMap<SyntaxContext, ScopeData>,
|
||||
|
||||
initialized_vars: IndexSet<Id, ahash::RandomState>,
|
||||
initialized_vars: IndexSet<Id, ARandomState>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
|
@ -16,7 +16,6 @@ default = ["serde-impl"]
|
||||
serde-impl = ["serde"]
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8.3"
|
||||
anyhow = "1"
|
||||
dashmap = "5.4.0"
|
||||
indexmap = "1.9.3"
|
||||
|
@ -1,7 +1,7 @@
|
||||
use indexmap::IndexSet;
|
||||
use preset_env_base::{version::should_enable, Versions};
|
||||
use swc_atoms::js_word;
|
||||
use swc_common::DUMMY_SP;
|
||||
use swc_common::{collections::ARandomState, DUMMY_SP};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
|
||||
|
||||
@ -11,7 +11,7 @@ use super::builtin::BUILTINS;
|
||||
pub struct Entry {
|
||||
is_any_target: bool,
|
||||
target: Versions,
|
||||
pub imports: IndexSet<&'static str, ahash::RandomState>,
|
||||
pub imports: IndexSet<&'static str, ARandomState>,
|
||||
}
|
||||
|
||||
impl Entry {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use indexmap::IndexSet;
|
||||
use preset_env_base::{version::should_enable, Versions};
|
||||
use swc_atoms::{js_word, JsWord};
|
||||
use swc_common::DUMMY_SP;
|
||||
use swc_common::{collections::ARandomState, DUMMY_SP};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
|
||||
|
||||
@ -19,7 +19,7 @@ mod entry;
|
||||
pub(crate) struct UsageVisitor {
|
||||
is_any_target: bool,
|
||||
target: Versions,
|
||||
pub required: IndexSet<&'static str, ahash::RandomState>,
|
||||
pub required: IndexSet<&'static str, ARandomState>,
|
||||
}
|
||||
|
||||
impl UsageVisitor {
|
||||
|
@ -5,7 +5,10 @@ use preset_env_base::{
|
||||
Versions,
|
||||
};
|
||||
use swc_atoms::js_word;
|
||||
use swc_common::{collections::AHashMap, DUMMY_SP};
|
||||
use swc_common::{
|
||||
collections::{AHashMap, ARandomState},
|
||||
DUMMY_SP,
|
||||
};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_visit::VisitMut;
|
||||
|
||||
@ -33,7 +36,7 @@ pub struct Entry {
|
||||
is_any_target: bool,
|
||||
target: Versions,
|
||||
corejs_version: Version,
|
||||
pub imports: IndexSet<&'static str, ahash::RandomState>,
|
||||
pub imports: IndexSet<&'static str, ARandomState>,
|
||||
remove_regenerator: bool,
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use indexmap::IndexSet;
|
||||
use preset_env_base::version::{should_enable, Version};
|
||||
use swc_atoms::{js_word, JsWord};
|
||||
use swc_common::DUMMY_SP;
|
||||
use swc_common::{collections::ARandomState, DUMMY_SP};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
|
||||
|
||||
@ -20,7 +20,7 @@ pub(crate) struct UsageVisitor {
|
||||
is_any_target: bool,
|
||||
target: Versions,
|
||||
corejs_version: Version,
|
||||
pub required: IndexSet<&'static str, ahash::RandomState>,
|
||||
pub required: IndexSet<&'static str, ARandomState>,
|
||||
}
|
||||
|
||||
impl UsageVisitor {
|
||||
|
@ -20,7 +20,6 @@ concurrent = [
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8.3"
|
||||
arrayvec = "0.7.2"
|
||||
indexmap = "1.9.3"
|
||||
is-macro = "0.3.0"
|
||||
|
@ -1,11 +1,13 @@
|
||||
use std::mem::take;
|
||||
|
||||
use ahash::AHashSet;
|
||||
use indexmap::IndexMap;
|
||||
use smallvec::SmallVec;
|
||||
use swc_atoms::{js_word, JsWord};
|
||||
use swc_common::{
|
||||
chain, collections::AHashMap, util::take::Take, Mark, Spanned, SyntaxContext, DUMMY_SP,
|
||||
chain,
|
||||
collections::{AHashMap, AHashSet},
|
||||
util::take::Take,
|
||||
Mark, Spanned, SyntaxContext, DUMMY_SP,
|
||||
};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_transforms_base::helper;
|
||||
@ -160,7 +162,7 @@ impl BlockScoping {
|
||||
has_return: false,
|
||||
has_yield: false,
|
||||
label: IndexMap::new(),
|
||||
inner_label: AHashSet::new(),
|
||||
inner_label: AHashSet::default(),
|
||||
mutated,
|
||||
in_switch_case: false,
|
||||
in_nested_loop: false,
|
||||
|
@ -1,6 +1,9 @@
|
||||
use indexmap::IndexMap;
|
||||
use swc_atoms::JsWord;
|
||||
use swc_common::{collections::AHashMap, Mark, SyntaxContext};
|
||||
use swc_common::{
|
||||
collections::{AHashMap, ARandomState},
|
||||
Mark, SyntaxContext,
|
||||
};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_transforms_base::scope::ScopeKind;
|
||||
use swc_ecma_visit::{noop_visit_mut_type, VisitMut, VisitMutWith};
|
||||
@ -24,7 +27,7 @@ struct BlockScopedVars {
|
||||
struct Scope {
|
||||
kind: ScopeKind,
|
||||
|
||||
vars: IndexMap<Id, VarDeclKind, ahash::RandomState>,
|
||||
vars: IndexMap<Id, VarDeclKind, ARandomState>,
|
||||
usages: Vec<Id>,
|
||||
|
||||
children: Vec<Scope>,
|
||||
@ -34,7 +37,7 @@ struct Scope {
|
||||
struct ParentScope<'a> {
|
||||
parent: Option<&'a ParentScope<'a>>,
|
||||
|
||||
vars: &'a IndexMap<Id, VarDeclKind, ahash::RandomState>,
|
||||
vars: &'a IndexMap<Id, VarDeclKind, ARandomState>,
|
||||
}
|
||||
|
||||
#[swc_trace]
|
||||
|
@ -1,7 +1,10 @@
|
||||
use std::iter;
|
||||
|
||||
use serde::Deserialize;
|
||||
use swc_common::{comments::Comments, util::take::Take, BytePos, Mark, Span, Spanned, DUMMY_SP};
|
||||
use swc_common::{
|
||||
collections::ARandomState, comments::Comments, util::take::Take, BytePos, Mark, Span, Spanned,
|
||||
DUMMY_SP,
|
||||
};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_transforms_base::{helper, native::is_native, perf::Check};
|
||||
use swc_ecma_transforms_classes::super_field::SuperFieldAccessFolder;
|
||||
@ -42,7 +45,7 @@ where
|
||||
})
|
||||
}
|
||||
|
||||
type IndexMap<K, V> = indexmap::IndexMap<K, V, ahash::RandomState>;
|
||||
type IndexMap<K, V> = indexmap::IndexMap<K, V, ARandomState>;
|
||||
|
||||
/// `@babel/plugin-transform-classes`
|
||||
///
|
||||
|
@ -14,7 +14,6 @@ bench = false
|
||||
|
||||
[dependencies]
|
||||
Inflector = "0.11.4"
|
||||
ahash = "0.8.3"
|
||||
anyhow = "1.0.71"
|
||||
bitflags = "2.3.2"
|
||||
indexmap = "1.9.3"
|
||||
|
@ -22,7 +22,6 @@ concurrent = [
|
||||
debug = []
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8.3"
|
||||
dashmap = "5.4.0"
|
||||
indexmap = "1.9.3"
|
||||
once_cell = "1.18.0"
|
||||
|
@ -8,6 +8,7 @@ use once_cell::sync::Lazy;
|
||||
use rustc_hash::FxHashMap;
|
||||
use swc_atoms::{js_word, JsWord};
|
||||
use swc_common::{
|
||||
collections::ARandomState,
|
||||
errors::HANDLER,
|
||||
sync::Lrc,
|
||||
util::{move_map::MoveMap, take::Take},
|
||||
@ -43,8 +44,7 @@ pub fn const_modules(
|
||||
}
|
||||
|
||||
fn parse_option(cm: &SourceMap, name: &str, src: String) -> Arc<Expr> {
|
||||
static CACHE: Lazy<DashMap<String, Arc<Expr>, ahash::RandomState>> =
|
||||
Lazy::new(DashMap::default);
|
||||
static CACHE: Lazy<DashMap<String, Arc<Expr>, ARandomState>> = Lazy::new(DashMap::default);
|
||||
|
||||
let fm = cm.new_source_file(FileName::Custom(format!("<const-module-{}.js>", name)), src);
|
||||
if let Some(expr) = CACHE.get(&**fm.src) {
|
||||
|
@ -5,7 +5,7 @@ use petgraph::{algo::tarjan_scc, Direction::Incoming};
|
||||
use rustc_hash::FxHashSet;
|
||||
use swc_atoms::{js_word, JsWord};
|
||||
use swc_common::{
|
||||
collections::{AHashMap, AHashSet},
|
||||
collections::{AHashMap, AHashSet, ARandomState},
|
||||
pass::{CompilerPass, Repeated},
|
||||
util::take::Take,
|
||||
Mark, SyntaxContext, DUMMY_SP,
|
||||
@ -113,7 +113,7 @@ struct Data {
|
||||
/// Entrypoints.
|
||||
entries: FxHashSet<u32>,
|
||||
|
||||
graph_ix: IndexSet<Id, ahash::RandomState>,
|
||||
graph_ix: IndexSet<Id, ARandomState>,
|
||||
}
|
||||
|
||||
impl Data {
|
||||
|
@ -8,7 +8,7 @@ use std::{
|
||||
|
||||
use indexmap::map::{Entry, IndexMap};
|
||||
use swc_atoms::js_word;
|
||||
use swc_common::collections::{AHashMap, AHashSet};
|
||||
use swc_common::collections::{AHashMap, AHashSet, ARandomState};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_transforms_base::ext::ExprRefExt;
|
||||
use tracing::{span, Level};
|
||||
@ -243,7 +243,7 @@ pub(super) struct Scope<'a> {
|
||||
pub kind: ScopeKind,
|
||||
|
||||
inline_barriers: RefCell<VecDeque<usize>>,
|
||||
bindings: IndexMap<Id, VarInfo, ahash::RandomState>,
|
||||
bindings: IndexMap<Id, VarInfo, ARandomState>,
|
||||
unresolved_usages: AHashSet<Id>,
|
||||
|
||||
/// Simple optimization. We don't need complex scope analysis.
|
||||
|
@ -18,7 +18,6 @@ default = ["serde-impl"]
|
||||
serde-impl = ["serde"]
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8.3"
|
||||
base64 = "0.13.0"
|
||||
dashmap = "5.4.0"
|
||||
indexmap = "1.9.3"
|
||||
|
@ -22,7 +22,6 @@ concurrent = ["swc_common/concurrent", "indexmap/rayon"]
|
||||
trace-ast = []
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8.3"
|
||||
indexmap = "1.9.3"
|
||||
rustc-hash = "1.1.0"
|
||||
tracing = "0.1.37"
|
||||
|
@ -12,9 +12,9 @@ version = "0.20.22"
|
||||
bench = false
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8.3"
|
||||
auto_impl = "1.1.0"
|
||||
petgraph = "0.6.0"
|
||||
swc_common = {version = "0.31.18", path = "../swc_common/"}
|
||||
swc_fast_graph = {version = "0.19.19", path = "../swc_fast_graph/"}
|
||||
tracing = "0.1.37"
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
use std::{fmt::Debug, hash::Hash, marker::PhantomData};
|
||||
|
||||
use ahash::AHashSet;
|
||||
use auto_impl::auto_impl;
|
||||
use swc_common::collections::AHashSet;
|
||||
use swc_fast_graph::digraph::FastDiGraphMap;
|
||||
|
||||
#[auto_impl(&, Box, Rc, Arc)]
|
||||
|
@ -15,7 +15,6 @@ version = "0.18.19"
|
||||
bench = false
|
||||
|
||||
[dependencies]
|
||||
ahash = "0.8.3"
|
||||
dashmap = "5.4.0"
|
||||
|
||||
swc_atoms = { version = "0.5.8", path = "../swc_atoms" }
|
||||
|
@ -5,11 +5,12 @@ use std::sync::Arc;
|
||||
use dashmap::DashMap;
|
||||
use swc_atoms::atom;
|
||||
use swc_common::{
|
||||
collections::ARandomState,
|
||||
comments::{Comment, CommentKind, Comments},
|
||||
BytePos, DUMMY_SP,
|
||||
};
|
||||
|
||||
type CommentMap = Arc<DashMap<BytePos, Vec<Comment>, ahash::RandomState>>;
|
||||
type CommentMap = Arc<DashMap<BytePos, Vec<Comment>, ARandomState>>;
|
||||
|
||||
/// Multi-threaded implementation of [Comments]
|
||||
#[derive(Clone, Default)]
|
||||
|
Loading…
Reference in New Issue
Block a user