Skip to content

Commit 0dce73a

Browse files
committed
Replace unordered_foreach_mut with map_inplace
1 parent a064023 commit 0dce73a

File tree

3 files changed

+9
-34
lines changed

3 files changed

+9
-34
lines changed

src/impl_methods.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,7 @@ where
19851985
S: DataMut,
19861986
A: Clone,
19871987
{
1988-
self.unordered_foreach_mut(move |elt| *elt = x.clone());
1988+
self.map_inplace(move |elt| *elt = x.clone());
19891989
}
19901990

19911991
fn zip_mut_with_same_shape<B, S2, E, F>(&mut self, rhs: &ArrayBase<S2, E>, mut f: F)
@@ -2037,7 +2037,7 @@ where
20372037
S: DataMut,
20382038
F: FnMut(&mut A, &B),
20392039
{
2040-
self.unordered_foreach_mut(move |elt| f(elt, rhs_elem));
2040+
self.map_inplace(move |elt| f(elt, rhs_elem));
20412041
}
20422042

20432043
/// Traverse two arrays in unspecified order, in lock step,
@@ -2232,7 +2232,7 @@ where
22322232
F: FnMut(A) -> A,
22332233
A: Clone,
22342234
{
2235-
self.unordered_foreach_mut(move |x| *x = f(x.clone()));
2235+
self.map_inplace(move |x| *x = f(x.clone()));
22362236
}
22372237

22382238
/// Call `f` for each element in the array.

src/impl_ops.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<A, S, D, B> $trt<B> for ArrayBase<S, D>
141141
{
142142
type Output = ArrayBase<S, D>;
143143
fn $mth(mut self, x: B) -> ArrayBase<S, D> {
144-
self.unordered_foreach_mut(move |elt| {
144+
self.map_inplace(move |elt| {
145145
*elt = elt.clone() $operator x.clone();
146146
});
147147
self
@@ -194,7 +194,7 @@ impl<S, D> $trt<ArrayBase<S, D>> for $scalar
194194
rhs.$mth(self)
195195
} or {{
196196
let mut rhs = rhs;
197-
rhs.unordered_foreach_mut(move |elt| {
197+
rhs.map_inplace(move |elt| {
198198
*elt = self $operator *elt;
199199
});
200200
rhs
@@ -299,7 +299,7 @@ mod arithmetic_ops {
299299
type Output = Self;
300300
/// Perform an elementwise negation of `self` and return the result.
301301
fn neg(mut self) -> Self {
302-
self.unordered_foreach_mut(|elt| {
302+
self.map_inplace(|elt| {
303303
*elt = -elt.clone();
304304
});
305305
self
@@ -329,7 +329,7 @@ mod arithmetic_ops {
329329
type Output = Self;
330330
/// Perform an elementwise unary not of `self` and return the result.
331331
fn not(mut self) -> Self {
332-
self.unordered_foreach_mut(|elt| {
332+
self.map_inplace(|elt| {
333333
*elt = !elt.clone();
334334
});
335335
self
@@ -386,7 +386,7 @@ mod assign_ops {
386386
D: Dimension,
387387
{
388388
fn $method(&mut self, rhs: A) {
389-
self.unordered_foreach_mut(move |elt| {
389+
self.map_inplace(move |elt| {
390390
elt.$method(rhs.clone());
391391
});
392392
}

src/lib.rs

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub use crate::indexes::{indices, indices_of};
143143
pub use crate::slice::{Slice, SliceInfo, SliceNextDim, SliceOrIndex};
144144

145145
use crate::iterators::Baseiter;
146-
use crate::iterators::{ElementsBase, ElementsBaseMut, Iter, IterMut, Lanes, LanesMut};
146+
use crate::iterators::{ElementsBase, ElementsBaseMut, Iter, IterMut, Lanes};
147147

148148
pub use crate::arraytraits::AsArray;
149149
#[cfg(feature = "std")]
@@ -1544,22 +1544,6 @@ where
15441544
self.strides.clone()
15451545
}
15461546

1547-
/// Apply closure `f` to each element in the array, in whatever
1548-
/// order is the fastest to visit.
1549-
fn unordered_foreach_mut<F>(&mut self, mut f: F)
1550-
where
1551-
S: DataMut,
1552-
F: FnMut(&mut A),
1553-
{
1554-
if let Some(slc) = self.as_slice_memory_order_mut() {
1555-
slc.iter_mut().for_each(f);
1556-
} else {
1557-
for row in self.inner_rows_mut() {
1558-
row.into_iter_().fold((), |(), elt| f(elt));
1559-
}
1560-
}
1561-
}
1562-
15631547
/// Remove array axis `axis` and return the result.
15641548
fn try_remove_axis(self, axis: Axis) -> ArrayBase<S, D::Smaller> {
15651549
let d = self.dim.try_remove_axis(axis);
@@ -1577,15 +1561,6 @@ where
15771561
let n = self.ndim();
15781562
Lanes::new(self.view(), Axis(n.saturating_sub(1)))
15791563
}
1580-
1581-
/// n-d generalization of rows, just like inner iter
1582-
fn inner_rows_mut(&mut self) -> iterators::LanesMut<'_, A, D::Smaller>
1583-
where
1584-
S: DataMut,
1585-
{
1586-
let n = self.ndim();
1587-
LanesMut::new(self.view_mut(), Axis(n.saturating_sub(1)))
1588-
}
15891564
}
15901565

15911566
// parallel methods

0 commit comments

Comments
 (0)