refactor(syntax): use FxHashMap for ModuleRecord::request_modules (#3124)

closes #3121

The ordering is not important here.
This commit is contained in:
Boshen 2024-04-29 11:37:34 +08:00 committed by GitHub
parent 14e4c58540
commit ae6561308c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 13 additions and 16 deletions

1
Cargo.lock generated
View file

@ -1621,7 +1621,6 @@ version = "0.12.5"
dependencies = [
"bitflags 2.5.0",
"dashmap",
"indexmap",
"oxc_index",
"oxc_span",
"phf",

View file

@ -141,7 +141,7 @@ impl Rule for NoCycle {
});
if visitor_result.result {
let span = module_record.requested_modules.get(&stack[0].0).unwrap()[0].span();
let span = module_record.requested_modules[&stack[0].0][0].span();
let help = stack
.iter()
.map(|(specifier, path)| {

View file

@ -369,17 +369,6 @@ expression: no_duplicates
13 │ }
╰────
⚠ eslint-plugin-import(no-duplicates): Forbid repeated import of the same module in multiple places
╭─[index.ts:1:19]
1 │ import {A1,} from 'foo';
· ─────
2 │ import {B1,} from 'foo';
· ─────
3 │ import {C1,} from 'foo';
· ─────
4 │
╰────
⚠ eslint-plugin-import(no-duplicates): Forbid repeated import of the same module in multiple places
╭─[index.ts:7:20]
6 │ A2,
@ -395,6 +384,17 @@ expression: no_duplicates
· ─────
╰────
⚠ eslint-plugin-import(no-duplicates): Forbid repeated import of the same module in multiple places
╭─[index.ts:1:19]
1 │ import {A1,} from 'foo';
· ─────
2 │ import {B1,} from 'foo';
· ─────
3 │ import {C1,} from 'foo';
· ─────
4 │
╰────
⚠ eslint-plugin-import(no-duplicates): Forbid repeated import of the same module in multiple places
╭─[index.ts:1:20]
1 │ import type x from './foo'; import type y from './foo'

View file

@ -25,7 +25,6 @@ oxc_span = { workspace = true }
unicode-id-start = { workspace = true }
bitflags = { workspace = true }
rustc-hash = { workspace = true }
indexmap = { workspace = true }
dashmap = { workspace = true }
phf = { workspace = true, features = ["macros"] }

View file

@ -3,7 +3,6 @@
use std::{fmt, hash::BuildHasherDefault, path::PathBuf, sync::Arc};
use dashmap::DashMap;
use indexmap::IndexMap;
use rustc_hash::{FxHashMap, FxHasher};
use oxc_span::{CompactStr, Span};
@ -32,7 +31,7 @@ pub struct ModuleRecord {
/// import ModuleSpecifier
/// export ExportFromClause FromClause
/// Keyed by ModuleSpecifier, valued by all node occurrences
pub requested_modules: IndexMap<CompactStr, Vec<RequestedModule>, BuildHasherDefault<FxHasher>>,
pub requested_modules: FxHashMap<CompactStr, Vec<RequestedModule>>,
/// `[[LoadedModules]]`
///