diff options
author | nils <48135649+Nilstrieb@users.noreply.github.com> | 2022-06-15 22:07:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-15 20:07:32 +0000 |
commit | ff7f74fd29945ec7913c7b99fd743298164c7888 (patch) | |
tree | b1a98cc670cd313c8a7be0bc5d7c24f755217816 | |
parent | d9c6c8d53e95be2fe40162a1fcfe21b93fa0444b (diff) | |
download | alacritty-ff7f74fd29945ec7913c7b99fd743298164c7888.tar.gz alacritty-ff7f74fd29945ec7913c7b99fd743298164c7888.zip |
Use `MaybeUninit<usize>` instead of `usize` in `Storage::swap`
`Row` contains pointer bytes, which are not valid for `usize`, therefore
`MaybeUninit<usize>` should be used instead to do an untyped copy.
-rw-r--r-- | alacritty_terminal/src/grid/storage.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/alacritty_terminal/src/grid/storage.rs b/alacritty_terminal/src/grid/storage.rs index 6fbc3bf2..e444d9c3 100644 --- a/alacritty_terminal/src/grid/storage.rs +++ b/alacritty_terminal/src/grid/storage.rs @@ -1,5 +1,6 @@ use std::cmp::{max, PartialEq}; use std::mem; +use std::mem::MaybeUninit; use std::ops::{Index, IndexMut}; use serde::{Deserialize, Serialize}; @@ -157,13 +158,13 @@ impl<T> Storage<T> { // Cast to a qword array to opt out of copy restrictions and avoid // drop hazards. Byte array is no good here since for whatever // reason LLVM won't optimized it. - let a_ptr = self.inner.as_mut_ptr().add(a) as *mut usize; - let b_ptr = self.inner.as_mut_ptr().add(b) as *mut usize; + let a_ptr = self.inner.as_mut_ptr().add(a) as *mut MaybeUninit<usize>; + let b_ptr = self.inner.as_mut_ptr().add(b) as *mut MaybeUninit<usize>; // Copy 1 qword at a time. // // The optimizer unrolls this loop and vectorizes it. - let mut tmp: usize; + let mut tmp: MaybeUninit<usize>; for i in 0..4 { tmp = *a_ptr.offset(i); *a_ptr.offset(i) = *b_ptr.offset(i); |