@@ -26,6 +26,11 @@ use crate::target::Target;
2626use crate :: types:: { MemberInfo , TypeId , TypeKind , TypeModifiers , TypeTable } ;
2727use std:: collections:: HashMap ;
2828
29+ /// Default capacity for variable mapping HashMaps during IR linearization
30+ const DEFAULT_VAR_MAP_CAPACITY : usize = 64 ;
31+ /// Default capacity for label/static HashMaps (typically smaller)
32+ const DEFAULT_LABEL_MAP_CAPACITY : usize = 16 ;
33+
2934/// Information about a local variable
3035#[ derive( Clone ) ]
3136struct LocalVarInfo {
@@ -127,9 +132,9 @@ impl<'a> Linearizer<'a> {
127132 current_bb : None ,
128133 next_pseudo : 0 ,
129134 next_bb : 0 ,
130- var_map : HashMap :: new ( ) ,
131- locals : HashMap :: new ( ) ,
132- label_map : HashMap :: new ( ) ,
135+ var_map : HashMap :: with_capacity ( DEFAULT_VAR_MAP_CAPACITY ) ,
136+ locals : HashMap :: with_capacity ( DEFAULT_VAR_MAP_CAPACITY ) ,
137+ label_map : HashMap :: with_capacity ( DEFAULT_LABEL_MAP_CAPACITY ) ,
133138 break_targets : Vec :: new ( ) ,
134139 continue_targets : Vec :: new ( ) ,
135140 run_ssa : true , // Enable SSA conversion by default
@@ -142,7 +147,7 @@ impl<'a> Linearizer<'a> {
142147 current_func_name : String :: new ( ) ,
143148 static_local_counter : 0 ,
144149 compound_literal_counter : 0 ,
145- static_locals : HashMap :: new ( ) ,
150+ static_locals : HashMap :: with_capacity ( DEFAULT_LABEL_MAP_CAPACITY ) ,
146151 current_pos : None ,
147152 target,
148153 current_func_is_non_static_inline : false ,
0 commit comments