Use copy_nonoverlapping to copy bytes in String::insert_bytes

This commit is contained in:
Paolo Barbolini 2021-06-18 15:14:22 +02:00
parent 966361fe49
commit d8530d0fa3

View File

@ -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);
}
}