Skip to content

Commit

Permalink
Auto merge of rust-lang#50631 - pietroalbini:beta-backports, r=alexcr…
Browse files Browse the repository at this point in the history
…ichton

[beta] Process backports

* rust-lang#50575: std: Avoid `ptr::copy` if unnecessary in `vec::Drain`

r? @alexcrichton
  • Loading branch information
bors committed May 11, 2018
2 parents 03fb2f4 + dfc9570 commit 1e057a2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2533,9 +2533,11 @@ impl<'a, T> Drop for Drain<'a, T> {
// memmove back untouched tail, update to new length
let start = source_vec.len();
let tail = self.tail_start;
let src = source_vec.as_ptr().offset(tail as isize);
let dst = source_vec.as_mut_ptr().offset(start as isize);
ptr::copy(src, dst, self.tail_len);
if tail != start {
let src = source_vec.as_ptr().offset(tail as isize);
let dst = source_vec.as_mut_ptr().offset(start as isize);
ptr::copy(src, dst, self.tail_len);
}
source_vec.set_len(start + self.tail_len);
}
}
Expand Down

0 comments on commit 1e057a2

Please sign in to comment.