1
- use std:: collections:: hash_map:: Entry ;
1
+ use std:: {
2
+ collections:: { hash_map:: Entry , HashMap } ,
3
+ hash:: BuildHasherDefault ,
4
+ } ;
2
5
3
- use rspack_collections:: { IdentifierMap , UkeyMap } ;
6
+ use rspack_collections:: { IdentifierHasher , IdentifierMap , UkeyMap } ;
4
7
use rspack_error:: Result ;
5
8
use rspack_hash:: RspackHashDigest ;
6
- use rustc_hash:: FxHashMap as HashMap ;
9
+ use rustc_hash:: FxHashMap ;
7
10
use swc_core:: ecma:: atoms:: Atom ;
8
11
9
12
use crate :: {
@@ -22,7 +25,7 @@ use crate::{
22
25
23
26
// TODO Here request can be used Atom
24
27
pub type ImportVarMap =
25
- HashMap < Option < ModuleIdentifier > /* request */ , String /* import_var */ > ;
28
+ FxHashMap < Option < ModuleIdentifier > /* request */ , String /* import_var */ > ;
26
29
27
30
/// https://github.com/webpack/webpack/blob/ac7e531436b0d47cd88451f497cdfd0dad41535d/lib/ModuleGraph.js#L742-L748
28
31
#[ derive( Debug ) ]
@@ -44,16 +47,20 @@ pub struct ModuleGraphPartial {
44
47
pub ( crate ) modules : IdentifierMap < Option < BoxModule > > ,
45
48
46
49
/// Dependencies indexed by `DependencyId`.
47
- dependencies : HashMap < DependencyId , Option < BoxDependency > > ,
50
+ dependencies : UkeyMap < DependencyId , Option < BoxDependency > > ,
48
51
49
52
/// AsyncDependenciesBlocks indexed by `AsyncDependenciesBlockIdentifier`.
50
- blocks : HashMap < AsyncDependenciesBlockIdentifier , Option < Box < AsyncDependenciesBlock > > > ,
53
+ blocks : HashMap <
54
+ AsyncDependenciesBlockIdentifier ,
55
+ Option < Box < AsyncDependenciesBlock > > ,
56
+ BuildHasherDefault < IdentifierHasher > ,
57
+ > ,
51
58
52
59
/// ModuleGraphModule indexed by `ModuleIdentifier`.
53
60
module_graph_modules : IdentifierMap < Option < ModuleGraphModule > > ,
54
61
55
62
/// ModuleGraphConnection indexed by `DependencyId`.
56
- connections : HashMap < DependencyId , Option < ModuleGraphConnection > > ,
63
+ connections : UkeyMap < DependencyId , Option < ModuleGraphConnection > > ,
57
64
58
65
/// Dependency_id to parent module identifier and parent block
59
66
///
@@ -73,13 +80,13 @@ pub struct ModuleGraphPartial {
73
80
/// assert_eq!(parents_info, parent_module_id);
74
81
/// })
75
82
/// ```
76
- dependency_id_to_parents : HashMap < DependencyId , Option < DependencyParents > > ,
83
+ dependency_id_to_parents : UkeyMap < DependencyId , Option < DependencyParents > > ,
77
84
78
85
// Module's ExportsInfo is also a part of ModuleGraph
79
86
exports_info_map : UkeyMap < ExportsInfo , ExportsInfoData > ,
80
87
export_info_map : UkeyMap < ExportInfo , ExportInfoData > ,
81
- connection_to_condition : HashMap < DependencyId , DependencyCondition > ,
82
- dep_meta_map : HashMap < DependencyId , DependencyExtraMeta > ,
88
+ connection_to_condition : UkeyMap < DependencyId , DependencyCondition > ,
89
+ dep_meta_map : UkeyMap < DependencyId , DependencyExtraMeta > ,
83
90
}
84
91
85
92
#[ derive( Debug , Default ) ]
@@ -190,13 +197,14 @@ impl<'a> ModuleGraph<'a> {
190
197
pub fn get_incoming_connections_by_origin_module (
191
198
& self ,
192
199
module_id : & ModuleIdentifier ,
193
- ) -> HashMap < Option < ModuleIdentifier > , Vec < ModuleGraphConnection > > {
200
+ ) -> FxHashMap < Option < ModuleIdentifier > , Vec < ModuleGraphConnection > > {
194
201
let connections = self
195
202
. module_graph_module_by_identifier ( module_id)
196
203
. expect ( "should have mgm" )
197
204
. incoming_connections ( ) ;
198
205
199
- let mut map: HashMap < Option < ModuleIdentifier > , Vec < ModuleGraphConnection > > = HashMap :: default ( ) ;
206
+ let mut map: FxHashMap < Option < ModuleIdentifier > , Vec < ModuleGraphConnection > > =
207
+ FxHashMap :: default ( ) ;
200
208
for dep_id in connections {
201
209
let con = self
202
210
. connection_by_dependency_id ( dep_id)
@@ -600,8 +608,8 @@ impl<'a> ModuleGraph<'a> {
600
608
. expect ( "block has been removed to None" )
601
609
}
602
610
603
- pub fn dependencies ( & self ) -> HashMap < DependencyId , & BoxDependency > {
604
- let mut res = HashMap :: default ( ) ;
611
+ pub fn dependencies ( & self ) -> UkeyMap < DependencyId , & BoxDependency > {
612
+ let mut res = UkeyMap :: default ( ) ;
605
613
for item in self . partials . iter ( ) {
606
614
for ( k, v) in & item. dependencies {
607
615
if let Some ( v) = v {
0 commit comments