Skip to content

Commit e4991b2

Browse files
authored
Rollup merge of rust-lang#49646 - glandium:uninitialized-box, r=alexcrichton
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.
2 parents ccd2c40 + 4577da7 commit e4991b2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libstd/sys/windows/mutex.rs

Lines changed: 1 addition & 1 deletion
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)