Skip to content

Commit 05dee0e

Browse files
initialize temp vector in advance
1 parent 3344cf8 commit 05dee0e

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/impl_methods.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3242,12 +3242,9 @@ impl<A, D: Dimension> ArrayRef<A, D>
32423242
lane.as_slice_mut().unwrap().select_nth_unstable(kth);
32433243
});
32443244
} else {
3245-
let mut temp_vec = Vec::with_capacity(axis_len);
3245+
let mut temp_vec = vec![A::zero(); axis_len];
32463246

32473247
Zip::from(result.lanes_mut(axis)).for_each(|mut lane| {
3248-
temp_vec.clear();
3249-
temp_vec.resize(axis_len, A::zero());
3250-
32513248
Zip::from(&mut temp_vec).and(&lane).for_each(|dest, src| {
32523249
*dest = src.clone();
32533250
});

0 commit comments

Comments
 (0)