mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-19 12:05:08 +00:00
Use the new load
/store
functions in {from,to}_slice
This commit is contained in:
parent
195d4cad50
commit
4967f25f6b
@ -263,11 +263,9 @@ where
|
||||
slice.len() >= Self::N,
|
||||
"slice length must be at least the number of elements"
|
||||
);
|
||||
assert!(core::mem::size_of::<Self>() == Self::N * core::mem::size_of::<T>());
|
||||
// Safety:
|
||||
// - We've checked the length is sufficient.
|
||||
// - `T` and `Simd<T, N>` are Copy types.
|
||||
unsafe { slice.as_ptr().cast::<Self>().read_unaligned() }
|
||||
// SAFETY: We just checked that the slice contains
|
||||
// at least `N` elements.
|
||||
unsafe { Self::load(slice.as_ptr().cast()) }
|
||||
}
|
||||
|
||||
/// Writes a SIMD vector to the first `N` elements of a slice.
|
||||
@ -293,11 +291,9 @@ where
|
||||
slice.len() >= Self::N,
|
||||
"slice length must be at least the number of elements"
|
||||
);
|
||||
assert!(core::mem::size_of::<Self>() == Self::N * core::mem::size_of::<T>());
|
||||
// Safety:
|
||||
// - We've checked the length is sufficient
|
||||
// - `T` and `Simd<T, N>` are Copy types.
|
||||
unsafe { slice.as_mut_ptr().cast::<Self>().write_unaligned(self) }
|
||||
// SAFETY: We just checked that the slice contains
|
||||
// at least `N` elements.
|
||||
unsafe { self.store(slice.as_mut_ptr().cast()) }
|
||||
}
|
||||
|
||||
/// Performs elementwise conversion of a SIMD vector's elements to another SIMD-valid type.
|
||||
|
Loading…
Reference in New Issue
Block a user