Skip to content

Commit 2af780f

Browse files
committed
FIX: Use faster iterator collect in as_standard_layout
1 parent 50573f8 commit 2af780f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/impl_methods.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1331,15 +1331,15 @@ where
13311331
if self.is_standard_layout() {
13321332
CowArray::from(self.view())
13331333
} else {
1334-
let v: Vec<A> = self.iter().cloned().collect();
1334+
let v = crate::iterators::to_vec_mapped(self.iter(), A::clone);
13351335
let dim = self.dim.clone();
1336-
assert_eq!(v.len(), dim.size());
1337-
let owned_array: Array<A, D> = unsafe {
1336+
debug_assert_eq!(v.len(), dim.size());
1337+
1338+
unsafe {
13381339
// Safe because the shape and element type are from the existing array
13391340
// and the strides are the default strides.
1340-
Array::from_shape_vec_unchecked(dim, v)
1341-
};
1342-
CowArray::from(owned_array)
1341+
CowArray::from(Array::from_shape_vec_unchecked(dim, v))
1342+
}
13431343
}
13441344
}
13451345

0 commit comments

Comments
 (0)