Use box syntax instead of Box::new in Mutex::remutex on Windows
The Box::new(mem::uninitialized()) pattern actually actively copies uninitialized bytes from the stack into the box, which is a waste of time. Using the box syntax instead avoids the useless copy.
This commit is contained in:
parent
199b7e211d
commit
4577da75f4
@ -117,7 +117,7 @@ impl Mutex {
|
|||||||
0 => {}
|
0 => {}
|
||||||
n => return n as *mut _,
|
n => return n as *mut _,
|
||||||
}
|
}
|
||||||
let mut re = Box::new(ReentrantMutex::uninitialized());
|
let mut re = box ReentrantMutex::uninitialized();
|
||||||
re.init();
|
re.init();
|
||||||
let re = Box::into_raw(re);
|
let re = Box::into_raw(re);
|
||||||
match self.lock.compare_and_swap(0, re as usize, Ordering::SeqCst) {
|
match self.lock.compare_and_swap(0, re as usize, Ordering::SeqCst) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user