Skip to content

Commit

Permalink
Rollup merge of rust-lang#49646 - glandium:uninitialized-box, r=alexc…
Browse files Browse the repository at this point in the history
…richton

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.
  • Loading branch information
kennytm authored Apr 16, 2018
2 parents ccd2c40 + 4577da7 commit e4991b2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/libstd/sys/windows/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl Mutex {
0 => {}
n => return n as *mut _,
}
let mut re = Box::new(ReentrantMutex::uninitialized());
let mut re = box ReentrantMutex::uninitialized();
re.init();
let re = Box::into_raw(re);
match self.lock.compare_and_swap(0, re as usize, Ordering::SeqCst) {
Expand Down

0 comments on commit e4991b2

Please sign in to comment.