From c62f433e46c8f3b122857021acb448e9b8fb7972 Mon Sep 17 00:00:00 2001 From: CohenArthur Date: Sun, 23 Aug 2020 15:00:09 +0200 Subject: [PATCH] remove_unused_stack_addr_and_stack_load: Remove clone() --- src/optimize/stack2reg.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/optimize/stack2reg.rs b/src/optimize/stack2reg.rs index d6a9d6228c4..cb68f1ccaf2 100644 --- a/src/optimize/stack2reg.rs +++ b/src/optimize/stack2reg.rs @@ -315,14 +315,13 @@ fn remove_unused_stack_addr_and_stack_load(opt_ctx: &mut OptimizeContext<'_>) { // Replace all unused stack_addr and stack_load instructions with nop. for stack_slot_users in opt_ctx.stack_slot_usage_map.values_mut() { - // FIXME remove clone - for &inst in stack_slot_users.stack_addr.clone().iter() { + while let Some(&inst) = stack_slot_users.stack_addr.iter().next() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { stack_slot_users.remove_unused_stack_addr(&mut opt_ctx.ctx.func, inst); } } - for &inst in stack_slot_users.stack_load.clone().iter() { + while let Some(&inst) = stack_slot_users.stack_load.iter().next() { if stack_addr_load_insts_users.get(&inst).map(|users| users.is_empty()).unwrap_or(true) { stack_slot_users.remove_unused_load(&mut opt_ctx.ctx.func, inst); }