Skip to content

Commit 0e2427c

Browse files
authored
Remove unneeded copy
1 parent 398aaff commit 0e2427c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/liballoc/vec.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2691,7 +2691,8 @@ impl<'a, T, F> Iterator for DrainFilter<'a, T, F>
26912691
self.del += 1;
26922692
return Some(ptr::read(&v[i]));
26932693
} else if self.del > 0 {
2694-
v.swap(i - self.del, i);
2694+
let del = self.del;
2695+
ptr::copy_nonoverlapping(self.vec.as_ptr().offset(i), self.vec.as_mut_ptr().offset(i - del), 1);
26952696
}
26962697
}
26972698
None

0 commit comments

Comments
 (0)