diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2f580fb..ae062ba 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -7,19 +7,9 @@ - - + - - - - - - - - - - + @@ -641,7 +632,6 @@ - @@ -666,7 +656,8 @@ - diff --git a/src/root/unrandom.rs b/src/root/unrandom.rs index ebd54db..3e13f2d 100644 --- a/src/root/unrandom.rs +++ b/src/root/unrandom.rs @@ -1,5 +1,4 @@ use std::hash::RandomState; -use std::{mem, ptr, slice}; use std::collections::{HashMap, HashSet}; #[inline] @@ -16,19 +15,9 @@ pub fn new_hashmap() -> HashMap { #[inline] pub fn unrandom_hashmap() -> HashMap { - let mut r = RandomState::new(); - let p: *mut RandomState = &mut r; - let p: *mut u8 = p as *mut u8; - let s: &mut [u8] = unsafe { - slice::from_raw_parts_mut(p, mem::size_of::()) + let r: RandomState = unsafe { + std::mem::transmute([0u8; size_of::()]) }; - unsafe { - for s in &mut *s { - let p: *const u8 = s; - let p: *mut u8 = p as *mut u8; - ptr::write_volatile(p, 0u8); - } - } HashMap::with_hasher(r) } @@ -47,19 +36,9 @@ pub fn new_hashset() -> HashSet { #[inline] pub fn unrandom_hashset() -> HashSet { - let mut r = RandomState::new(); - let p: *mut RandomState = &mut r; - let p: *mut u8 = p as *mut u8; - let s: &mut [u8] = unsafe { - slice::from_raw_parts_mut(p, mem::size_of::()) + let r: RandomState = unsafe { + std::mem::transmute([0u8; size_of::()]) }; - unsafe { - for s in &mut *s { - let p: *const u8 = s; - let p: *mut u8 = p as *mut u8; - ptr::write_volatile(p, 0u8); - } - } HashSet::with_hasher(r) } \ No newline at end of file