@@ -827,14 +827,18 @@ pub(crate) fn assign_dyn_import_chunk_short_names(compilation: &mut Compilation)
827827 let module_graph = compilation. get_module_graph ( ) ;
828828
829829 // Collect all existing named chunks
830- let mut used_names: FxHashMap < String , usize > = FxHashMap :: default ( ) ;
830+ let mut used_names: FxHashMap < String , usize > = FxHashMap :: with_capacity_and_hasher (
831+ compilation. build_chunk_graph_artifact . named_chunks . len ( ) ,
832+ Default :: default ( ) ,
833+ ) ;
831834 for name in compilation. build_chunk_graph_artifact . named_chunks . keys ( ) {
832835 used_names. insert ( name. clone ( ) , 1 ) ;
833836 }
834837
835838 // Collect candidates: (chunk_ukey, root_module_identifier) for unnamed non-initial chunks
836839 // with exactly one root module
837- let mut candidates: Vec < ( ChunkUkey , ModuleIdentifier ) > = Vec :: new ( ) ;
840+ let mut candidates: Vec < ( ChunkUkey , ModuleIdentifier ) > =
841+ Vec :: with_capacity ( compilation. build_chunk_graph_artifact . chunk_by_ukey . len ( ) ) ;
838842
839843 for ( chunk_ukey, chunk) in compilation. build_chunk_graph_artifact . chunk_by_ukey . iter ( ) {
840844 // Skip chunks that already have a name
@@ -867,8 +871,10 @@ pub(crate) fn assign_dyn_import_chunk_short_names(compilation: &mut Compilation)
867871
868872 // Compute short names and track duplicates
869873 // name_to_chunks: maps base_name → list of (chunk_ukey, module_identifier) in sorted order
870- let mut name_to_chunks: Vec < ( String , Vec < ( ChunkUkey , ModuleIdentifier ) > ) > = Vec :: new ( ) ;
871- let mut name_index_map: FxHashMap < String , usize > = FxHashMap :: default ( ) ;
874+ let mut name_to_chunks: Vec < ( String , Vec < ( ChunkUkey , ModuleIdentifier ) > ) > =
875+ Vec :: with_capacity ( candidates. len ( ) ) ;
876+ let mut name_index_map: FxHashMap < String , usize > =
877+ FxHashMap :: with_capacity_and_hasher ( candidates. len ( ) , Default :: default ( ) ) ;
872878
873879 for ( chunk_ukey, module_id) in & candidates {
874880 let Some ( module_path) = module_graph
@@ -891,7 +897,7 @@ pub(crate) fn assign_dyn_import_chunk_short_names(compilation: &mut Compilation)
891897 }
892898
893899 // Assign names, handling deduplication
894- let mut assignments: Vec < ( ChunkUkey , String ) > = Vec :: new ( ) ;
900+ let mut assignments: Vec < ( ChunkUkey , String ) > = Vec :: with_capacity ( candidates . len ( ) ) ;
895901
896902 for ( base_name, chunks) in & name_to_chunks {
897903 if chunks. len ( ) == 1 && !used_names. contains_key ( base_name) {
0 commit comments