From 5c8c75b1d2a1fd8146daf71a3ef05acdca406d0b Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sun, 23 Aug 2020 18:36:42 +0200 Subject: [PATCH] stack2reg: Drain instead of only iterating --- src/optimize/stack2reg.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index 72762f563d3..d1826a9af72 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -316,15 +316,15 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() { stack_slot_users .stack_addr - .iter() + .drain() .filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true)) - .for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, *inst)); + .for_each(|inst| StackSlotUsage::remove_unused_stack_addr(&mut func, inst)); stack_slot_users .stack_load - .iter() + .drain() .filter(|inst| stack_addr_load_insts_users.get(inst).map(|users| users.is_empty()).unwrap_or(true)) - .for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, *inst)); + .for_each(|inst| StackSlotUsage::remove_unused_load(&mut func, inst)); } }