Skip to content

Commit

Permalink
Use drain instead of clear (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottt authored Apr 6, 2023
1 parent 9c6d6dc commit f0e9cde
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/ion/redundant_moves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,18 @@ impl RedundantMoveEliminator {
pub fn clear_alloc(&mut self, alloc: Allocation) {
trace!(" redundant move eliminator: clear {:?}", alloc);
if let Some(ref mut existing_copies) = self.reverse_allocs.get_mut(&alloc) {
for to_inval in existing_copies.iter() {
for to_inval in existing_copies.drain(..) {
trace!(" -> clear existing copy: {:?}", to_inval);
if let Some(val) = self.allocs.get_mut(to_inval) {
if let Some(val) = self.allocs.get_mut(&to_inval) {
match val {
RedundantMoveState::Copy(_, Some(vreg)) => {
*val = RedundantMoveState::Orig(*vreg);
}
_ => *val = RedundantMoveState::None,
}
}
self.allocs.remove(to_inval);
self.allocs.remove(&to_inval);
}
existing_copies.clear();
}
self.allocs.remove(&alloc);
}
Expand Down

0 comments on commit f0e9cde

Please sign in to comment.