use crate::cpu::CPU_SIMD_64_SIZE;
#[inline]
pub fn copy_simd_slice<'a, const LANE_SIZE: usize>(src: &[u8], mut dst: &'a mut [u8]) -> &'a mut [u8] {
let (prefix, middle, postfix) = src.as_simd::<LANE_SIZE>();
let prefix_len = prefix.len();
let postfix_len = postfix.len();
dst[..prefix_len].copy_from_slice(prefix);
dst = &mut dst[prefix_len..];
for chunk in middle.into_iter() {
chunk.copy_to_slice(&mut dst[..LANE_SIZE]);
dst = &mut dst[LANE_SIZE..];
}
dst[..postfix_len].copy_from_slice(postfix);
dst
}
#[inline]
pub fn copy_from_slice<'a>(src: &[u8], dst: &'a mut [u8]) -> &'a mut [u8] {
debug_assert!(src.len() <= dst.len(), "Destination memory slice is smaller than source! This is a bug near the call site of copy_from_slice!");
copy_simd_slice::<CPU_SIMD_64_SIZE>(
src,
dst,
)
}
#[macro_export]
macro_rules! rumtk_mem_quick_array_init {
( $typ:ty, $size:expr ) => {{
const DATA_SLICE_LEN: usize = $size * size_of::<$typ>();
let arr: [$typ; $size] = unsafe { mem::transmute([0u8; DATA_SLICE_LEN]) };
arr
}};
( $typ:ty, $size:expr, $default:expr ) => {{
let arr: [$typ; $size] = [const {$default}; $size];
arr
}};
}