refactor(syntax): use allocator HashMap in ModuleRecord fields (#14141)

This commit is contained in:
Boshen committed 2025-09-27 08:22:20 +00:00
1 parent f1047e95ef
commit 7e42b0a68e
5 files changed
+11 -14

No files matched your search

Generated
-1
View File
@@ -2376,7 +2376,6 @@ dependencies = [
"oxc_index",
"oxc_span",
"phf",
"rustc-hash",
"serde",
"unicode-id-start",
]
+1
View File
@@ -48,6 +48,7 @@ type FxHashMap<'alloc, K, V> = hashbrown::HashMap<K, V, FxBuildHasher, &'alloc B
/// a [`HashMap`] will refuse to compile if either key or value is a [`Drop`] type.
///
/// [`FxHasher`]: rustc_hash::FxHasher
#[derive(Debug)]
pub struct HashMap<'alloc, K, V>(ManuallyDrop<FxHashMap<'alloc, K, V>>);
/// SAFETY: Even though `Bump` is not `Sync`, we can make `HashMap<K, V>` `Sync` if both `K` and `V`
-1
View File
@@ -31,7 +31,6 @@ bitflags = { workspace = true }
cow-utils = { workspace = true }
nonmax = { workspace = true }
phf = { workspace = true, features = ["macros"] }
rustc-hash = { workspace = true }
unicode-id-start = { workspace = true }
dragonbox_ecma = { workspace = true, optional = true }
+5 -7
View File
@@ -1,8 +1,6 @@
//! [ECMAScript Module Record](https://tc39.es/ecma262/#sec-abstract-module-records)
use rustc_hash::FxHashMap;
use oxc_allocator::{Allocator, Vec};
use oxc_allocator::{Allocator, HashMap, Vec};
use oxc_ast_macros::ast;
use oxc_estree::ESTree;
use oxc_span::{Atom, Span};
@@ -29,7 +27,7 @@ pub struct ModuleRecord<'a> {
/// export ExportFromClause FromClause
///
/// Keyed by ModuleSpecifier, valued by all node occurrences
pub requested_modules: FxHashMap<Atom<'a>, Vec<'a, RequestedModule>>,
pub requested_modules: HashMap<'a, Atom<'a>, Vec<'a, RequestedModule>>,
/// `[[ImportEntries]]`
///
@@ -57,7 +55,7 @@ pub struct ModuleRecord<'a> {
pub star_export_entries: Vec<'a, ExportEntry<'a>>,
/// Local exported bindings
pub exported_bindings: FxHashMap<Atom<'a>, Span>,
pub exported_bindings: HashMap<'a, Atom<'a>, Span>,
/// Dynamic import expressions `import(specifier)`.
pub dynamic_imports: Vec<'a, DynamicImport>,
@@ -71,12 +69,12 @@ impl<'a> ModuleRecord<'a> {
pub fn new(allocator: &'a Allocator) -> Self {
Self {
has_module_syntax: false,
requested_modules: FxHashMap::default(),
requested_modules: HashMap::new_in(allocator),
import_entries: Vec::new_in(allocator),
local_export_entries: Vec::new_in(allocator),
indirect_export_entries: Vec::new_in(allocator),
star_export_entries: Vec::new_in(allocator),
exported_bindings: FxHashMap::default(),
exported_bindings: HashMap::new_in(allocator),
dynamic_imports: Vec::new_in(allocator),
import_metas: Vec::new_in(allocator),
}
@@ -1,14 +1,14 @@
File | File size || Sys allocs | Sys reallocs || Arena allocs | Arena reallocs | Arena bytes
-------------------------------------------------------------------------------------------------------------------------------------------
checker.ts | 2.92 MB || 10161 | 21 || 268665 | 23341
checker.ts | 2.92 MB || 10157 | 21 || 268665 | 23341
cal.com.tsx | 1.06 MB || 2213 | 54 || 138188 | 13712
cal.com.tsx | 1.06 MB || 2197 | 54 || 138188 | 13712
RadixUIAdoptionSection.jsx | 2.52 kB || 4 | 0 || 365 | 66
RadixUIAdoptionSection.jsx | 2.52 kB || 1 | 0 || 365 | 66
pdf.mjs | 567.30 kB || 688 | 71 || 90678 | 8148
pdf.mjs | 567.30 kB || 683 | 71 || 90678 | 8148
antd.js | 6.69 MB || 6938 | 236 || 528505 | 55357
binder.ts | 193.08 kB || 540 | 7 || 16807 | 1475
binder.ts | 193.08 kB || 537 | 7 || 16807 | 1475