Skip to content

Commit ba07345

Browse files
committed
FIX: Use maybe_uninit in benchmarks
1 parent 5e9a01f commit ba07345

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

benches/bench1.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
extern crate test;
1111

12+
use std::mem::MaybeUninit;
13+
1214
use ndarray::ShapeBuilder;
1315
use ndarray::{arr0, arr1, arr2, azip, s};
1416
use ndarray::{Array, Array1, Array2, Axis, Ix, Zip};
@@ -269,9 +271,9 @@ fn add_2d_alloc_zip_uninit(bench: &mut test::Bencher) {
269271
let a = Array::<i32, _>::zeros((ADD2DSZ, ADD2DSZ));
270272
let b = Array::<i32, _>::zeros((ADD2DSZ, ADD2DSZ));
271273
bench.iter(|| unsafe {
272-
let mut c = Array::uninitialized(a.dim());
273-
azip!((&a in &a, &b in &b, c in c.raw_view_mut())
274-
std::ptr::write(c, a + b)
274+
let mut c = Array::<MaybeUninit<i32>, _>::maybe_uninit(a.dim());
275+
azip!((&a in &a, &b in &b, c in c.raw_view_mut().cast::<i32>())
276+
c.write(a + b)
275277
);
276278
c
277279
});

0 commit comments

Comments
 (0)