@@ -136,8 +136,9 @@ impl Mangler {
136
136
137
137
let mut slot_liveness: std:: vec:: Vec < FixedBitSet > = vec ! [ ] ;
138
138
139
- // Walk the scope tree and compute the slot number for each scope
140
139
let mut tmp_bindings = std:: vec:: Vec :: with_capacity ( 100 ) ;
140
+ let mut reusable_slots = std:: vec:: Vec :: new ( ) ;
141
+ // Walk the scope tree and compute the slot number for each scope
141
142
for scope_id in iter:: once ( scope_tree. root_scope_id ( ) )
142
143
. chain ( scope_tree. iter_all_child_ids ( scope_tree. root_scope_id ( ) ) )
143
144
{
@@ -153,19 +154,20 @@ impl Mangler {
153
154
. find ( |s_id| scope_tree. get_flags ( * s_id) . is_var ( ) )
154
155
. unwrap_or ( scope_tree. root_scope_id ( ) ) ;
155
156
156
- let reusable_slots = Vec :: from_iter_in (
157
+ reusable_slots. clear ( ) ;
158
+ reusable_slots. extend (
157
159
slot_liveness
158
160
. iter ( )
159
161
. enumerate ( )
160
162
. filter ( |( _, slot_liveness) | !slot_liveness. contains ( scope_id. index ( ) ) )
161
163
. map ( |( slot, _) | slot)
162
164
. take ( bindings. len ( ) ) ,
163
- & allocator,
164
165
) ;
165
166
166
167
let remaining_count = bindings. len ( ) - reusable_slots. len ( ) ;
167
168
168
- let assignable_slots = reusable_slots. into_iter ( ) . chain ( slot..slot + remaining_count) ;
169
+ reusable_slots. extend ( slot..slot + remaining_count) ;
170
+
169
171
slot += remaining_count;
170
172
if slot_liveness. len ( ) < slot {
171
173
slot_liveness. resize_with ( slot, || FixedBitSet :: with_capacity ( scope_tree. len ( ) ) ) ;
@@ -175,7 +177,9 @@ impl Mangler {
175
177
tmp_bindings. clear ( ) ;
176
178
tmp_bindings. extend ( bindings. values ( ) . copied ( ) ) ;
177
179
tmp_bindings. sort_unstable ( ) ;
178
- for ( symbol_id, assigned_slot) in tmp_bindings. iter ( ) . zip ( assignable_slots) {
180
+ for ( symbol_id, assigned_slot) in
181
+ tmp_bindings. iter ( ) . zip ( reusable_slots. iter ( ) . copied ( ) )
182
+ {
179
183
slots[ symbol_id. index ( ) ] = assigned_slot;
180
184
181
185
let lived_scope_ids = symbol_table
0 commit comments