Skip to content

Commit 4577da7

Browse files
committed
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.
1 parent 199b7e2 commit 4577da7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libstd/sys/windows/mutex.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl Mutex {
117117
0 => {}
118118
n => return n as *mut _,
119119
}
120-
let mut re = Box::new(ReentrantMutex::uninitialized());
120+
let mut re = box ReentrantMutex::uninitialized();
121121
re.init();
122122
let re = Box::into_raw(re);
123123
match self.lock.compare_and_swap(0, re as usize, Ordering::SeqCst) {

0 commit comments

Comments
 (0)