mirror of
https://github.com/denoland/rusty_v8.git
synced 2024-11-21 15:04:33 -05:00
fix: Use unaligned read as copy_nonoverlapping requires alignment (#1278)
This commit is contained in:
parent
9d5c21ae7e
commit
226c662da6
1 changed files with 3 additions and 5 deletions
|
@ -234,14 +234,12 @@ impl FastApiOneByteString {
|
|||
}
|
||||
|
||||
impl<T: Default> FastApiTypedArray<T> {
|
||||
/// Performs an unaligned-safe read of T from the underlying data.
|
||||
#[inline(always)]
|
||||
pub fn get(&self, index: usize) -> T {
|
||||
debug_assert!(index < self.length);
|
||||
let mut t: T = Default::default();
|
||||
unsafe {
|
||||
ptr::copy_nonoverlapping(self.data.add(index), &mut t, 1);
|
||||
}
|
||||
t
|
||||
// SAFETY: src is valid for reads, and is a valid value for T
|
||||
unsafe { ptr::read_unaligned(self.data.add(index)) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
|
Loading…
Reference in a new issue