@@ -2,8 +2,8 @@ use std::sync::Arc;
2
2
3
3
use either:: Either ;
4
4
use itertools:: Itertools ;
5
+ use rspack_collections:: UkeyMap ;
5
6
use rspack_util:: { atom:: Atom , ext:: DynHash } ;
6
- use rustc_hash:: FxHashMap as HashMap ;
7
7
8
8
use super :: {
9
9
ExportInfoData , ExportProvided , ExportsInfo , ProvidedExports , UsageState , UsedName , UsedNameItem ,
@@ -31,7 +31,7 @@ pub struct PrefetchedExportsInfoWrapper<'a> {
31
31
* stored in a map to prevent circular references
32
32
* When redirect, this data can be cloned to generate a new PrefetchedExportsInfoWrapper with a new entry
33
33
*/
34
- exports : Arc < HashMap < ExportsInfo , & ' a ExportsInfoData > > ,
34
+ exports : Arc < UkeyMap < ExportsInfo , & ' a ExportsInfoData > > ,
35
35
/**
36
36
* The entry of the current exports info
37
37
*/
@@ -569,7 +569,7 @@ impl ExportsInfoGetter {
569
569
fn prefetch_exports < ' a > (
570
570
id : & ExportsInfo ,
571
571
mg : & ' a ModuleGraph ,
572
- res : & mut HashMap < ExportsInfo , & ' a ExportsInfoData > ,
572
+ res : & mut UkeyMap < ExportsInfo , & ' a ExportsInfoData > ,
573
573
mode : PrefetchExportsInfoMode < ' a > ,
574
574
) {
575
575
if res. contains_key ( id) {
@@ -581,15 +581,12 @@ impl ExportsInfoGetter {
581
581
match mode {
582
582
PrefetchExportsInfoMode :: Default => { }
583
583
PrefetchExportsInfoMode :: Nested ( names) => {
584
- for ( key, export_info) in exports_info. exports ( ) . iter ( ) {
585
- if names. first ( ) . is_some_and ( |name| name == key)
586
- && let Some ( nested_exports_info) = export_info. exports_info ( )
587
- {
588
- nested_exports. push ( (
589
- nested_exports_info,
590
- PrefetchExportsInfoMode :: Nested ( & names[ 1 ..] ) ,
591
- ) ) ;
592
- }
584
+ if let Some ( nested) = names
585
+ . first ( )
586
+ . and_then ( |name| exports_info. exports ( ) . get ( name) )
587
+ . and_then ( |export_info| export_info. exports_info ( ) )
588
+ {
589
+ nested_exports. push ( ( nested, PrefetchExportsInfoMode :: Nested ( & names[ 1 ..] ) ) ) ;
593
590
}
594
591
}
595
592
PrefetchExportsInfoMode :: Full => {
@@ -620,7 +617,7 @@ impl ExportsInfoGetter {
620
617
}
621
618
}
622
619
623
- let mut res = HashMap :: default ( ) ;
620
+ let mut res = UkeyMap :: default ( ) ;
624
621
prefetch_exports ( id, mg, & mut res, mode. clone ( ) ) ;
625
622
PrefetchedExportsInfoWrapper {
626
623
exports : Arc :: new ( res) ,
@@ -748,7 +745,7 @@ impl ExportsInfoGetter {
748
745
let exports = exports
749
746
. into_iter ( )
750
747
. map ( |e| ( e, mg. get_exports_info_by_id ( & e) ) )
751
- . collect :: < HashMap < _ , _ > > ( ) ;
748
+ . collect :: < UkeyMap < _ , _ > > ( ) ;
752
749
753
750
PrefetchedExportsInfoWrapper {
754
751
exports : Arc :: new ( exports) ,
0 commit comments