Skip to content

Commit f0e9cde

Browse files
authored
Use drain instead of clear (#123)
1 parent 9c6d6dc commit f0e9cde

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/ion/redundant_moves.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,18 @@ impl RedundantMoveEliminator {
111111
pub fn clear_alloc(&mut self, alloc: Allocation) {
112112
trace!(" redundant move eliminator: clear {:?}", alloc);
113113
if let Some(ref mut existing_copies) = self.reverse_allocs.get_mut(&alloc) {
114-
for to_inval in existing_copies.iter() {
114+
for to_inval in existing_copies.drain(..) {
115115
trace!(" -> clear existing copy: {:?}", to_inval);
116-
if let Some(val) = self.allocs.get_mut(to_inval) {
116+
if let Some(val) = self.allocs.get_mut(&to_inval) {
117117
match val {
118118
RedundantMoveState::Copy(_, Some(vreg)) => {
119119
*val = RedundantMoveState::Orig(*vreg);
120120
}
121121
_ => *val = RedundantMoveState::None,
122122
}
123123
}
124-
self.allocs.remove(to_inval);
124+
self.allocs.remove(&to_inval);
125125
}
126-
existing_copies.clear();
127126
}
128127
self.allocs.remove(&alloc);
129128
}

0 commit comments

Comments
 (0)