Skip to content

Commit 5c8c75b

Browse files
committed
stack2reg: Drain instead of only iterating
1 parent eb6df58 commit 5c8c75b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/optimize/stack2reg.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,15 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) {
316316
for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() {
317317
stack_slot_users
318318
.stack_addr
319-
.iter()
319+
.drain()
320320
.filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true))
321-
.for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, *inst));
321+
.for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, inst));
322322

323323
stack_slot_users
324324
.stack_load
325-
.iter()
325+
.drain()
326326
.filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true))
327-
.for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, *inst));
327+
.for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, inst));
328328
}
329329
}
330330

0 commit comments

Comments
 (0)