Skip to content

Commit 5a46643

Browse files
committed
Avoid mem::uninitialized in par_sort_unstable
A couple temporary `[u8; 128]` arrays were uninitialized, and are now initialized to zeros. This has no measurable affect on the benchmarks for `par_sort_unstable`.
1 parent 73b1061 commit 5a46643

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/slice/quicksort.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,14 +256,14 @@ where
256256
let mut block_l = BLOCK;
257257
let mut start_l = ptr::null_mut();
258258
let mut end_l = ptr::null_mut();
259-
let mut offsets_l: [u8; BLOCK] = unsafe { mem::uninitialized() };
259+
let mut offsets_l = [0u8; BLOCK];
260260

261261
// The current block on the right side (from `r.offset(-block_r)` to `r`).
262262
let mut r = unsafe { l.add(v.len()) };
263263
let mut block_r = BLOCK;
264264
let mut start_r = ptr::null_mut();
265265
let mut end_r = ptr::null_mut();
266-
let mut offsets_r: [u8; BLOCK] = unsafe { mem::uninitialized() };
266+
let mut offsets_r = [0u8; BLOCK];
267267

268268
// Returns the number of elements between pointers `l` (inclusive) and `r` (exclusive).
269269
fn width<T>(l: *mut T, r: *mut T) -> usize {

0 commit comments

Comments
 (0)