Skip to content

Commit

Permalink
Avoid mem::uninitialized in par_sort_unstable
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
cuviper committed Nov 20, 2019
1 parent 73b1061 commit 5a46643
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/slice/quicksort.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,14 @@ where
let mut block_l = BLOCK;
let mut start_l = ptr::null_mut();
let mut end_l = ptr::null_mut();
let mut offsets_l: [u8; BLOCK] = unsafe { mem::uninitialized() };
let mut offsets_l = [0u8; BLOCK];

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

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

0 comments on commit 5a46643

Please sign in to comment.