Skip to content

Commit

Permalink
Use copy_nonoverlapping to copy bytes in String::insert_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
paolobarbolini committed Jun 18, 2021
1 parent 966361f commit d8530d0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion library/alloc/src/string.rs
Expand Up @@ -1451,7 +1451,7 @@ impl String {

unsafe {
ptr::copy(self.vec.as_ptr().add(idx), self.vec.as_mut_ptr().add(idx + amt), len - idx);
ptr::copy(bytes.as_ptr(), self.vec.as_mut_ptr().add(idx), amt);
ptr::copy_nonoverlapping(bytes.as_ptr(), self.vec.as_mut_ptr().add(idx), amt);
self.vec.set_len(len + amt);
}
}
Expand Down

0 comments on commit d8530d0

Please sign in to comment.