From 511e1b187d02e8cf0b320b23f48557925e4871d5 Mon Sep 17 00:00:00 2001 From: Tobias Stark Date: Tue, 8 Oct 2024 13:04:11 +0000 Subject: [PATCH] Use copy_nonoverlapping for more efficient sequence filling --- r2r_rcl/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/r2r_rcl/src/lib.rs b/r2r_rcl/src/lib.rs index 54eb13567..efb189ed3 100644 --- a/r2r_rcl/src/lib.rs +++ b/r2r_rcl/src/lib.rs @@ -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()); } } } @@ -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