Use copy_nonoverlapping
to copy bytes
in String::insert_bytes
This commit is contained in:
parent
966361fe49
commit
d8530d0fa3
@ -1451,7 +1451,7 @@ unsafe fn insert_bytes(&mut self, idx: usize, bytes: &[u8]) {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user