Skip to content

Commit

Permalink
Use copy_nonoverlapping for more efficient sequence filling
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasstarkwayve committed Oct 9, 2024
1 parent c56961e commit d2aa689
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions r2r_rcl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ macro_rules! primitive_sequence {
unsafe { [<$ctype __Sequence__fini>] (self as *mut _); }
unsafe { [<$ctype __Sequence__init>] (self as *mut _, values.len()); }
if self.data != std::ptr::null_mut() {
unsafe { std::ptr::copy(values.as_ptr(), self.data, values.len()); }
unsafe { std::ptr::copy_nonoverlapping(values.as_ptr(), self.data, values.len()); }
}
}

Expand All @@ -126,7 +126,7 @@ macro_rules! primitive_sequence {
}
let mut target = Vec::with_capacity(self.size);
unsafe {
std::ptr::copy(self.data, target.as_mut_ptr(), self.size);
std::ptr::copy_nonoverlapping(self.data, target.as_mut_ptr(), self.size);
target.set_len(self.size);
}
target
Expand Down

0 comments on commit d2aa689

Please sign in to comment.