Skip to content

Commit c4b562d

Browse files
committed
FEAT: Also used OwnedRepr for ArcArray
1 parent 66ab786 commit c4b562d

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/data_traits.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
//! The data (inner representation) traits for ndarray
1010
11-
use crate::extension::nonnull::nonnull_from_vec_data;
1211
use rawpointer::PointerExt;
1312
use std::mem::{self, size_of};
1413
use std::ptr::NonNull;
@@ -188,7 +187,7 @@ unsafe impl<A> RawDataClone for RawViewRepr<*mut A> {
188187
unsafe impl<A> RawData for OwnedArcRepr<A> {
189188
type Elem = A;
190189
fn _data_slice(&self) -> Option<&[A]> {
191-
Some(&self.0)
190+
Some(self.0.as_slice())
192191
}
193192
private_impl! {}
194193
}
@@ -226,7 +225,7 @@ where
226225
};
227226
let rvec = Arc::make_mut(rcvec);
228227
unsafe {
229-
self_.ptr = nonnull_from_vec_data(rvec).offset(our_off);
228+
self_.ptr = rvec.as_nonnull_mut().offset(our_off);
230229
}
231230
}
232231

@@ -242,7 +241,7 @@ unsafe impl<A> Data for OwnedArcRepr<A> {
242241
D: Dimension,
243242
{
244243
Self::ensure_unique(&mut self_);
245-
let data = OwnedRepr::from(Arc::try_unwrap(self_.data.0).ok().unwrap());
244+
let data = Arc::try_unwrap(self_.data.0).ok().unwrap();
246245
ArrayBase {
247246
data,
248247
ptr: self_.ptr,
@@ -416,13 +415,13 @@ unsafe impl<A> DataOwned for OwnedRepr<A> {
416415
OwnedRepr::from(elements)
417416
}
418417
fn into_shared(self) -> OwnedRcRepr<A> {
419-
OwnedArcRepr(Arc::new(self.into_vec()))
418+
OwnedArcRepr(Arc::new(self))
420419
}
421420
}
422421

423422
unsafe impl<A> DataOwned for OwnedArcRepr<A> {
424423
fn new(elements: Vec<A>) -> Self {
425-
OwnedArcRepr(Arc::new(elements))
424+
OwnedArcRepr(Arc::new(OwnedRepr::from(elements)))
426425
}
427426

428427
fn into_shared(self) -> OwnedRcRepr<A> {

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1402,7 +1402,7 @@ pub use self::OwnedArcRepr as OwnedRcRepr;
14021402
/// *Don’t use this type directly—use the type alias
14031403
/// [`ArcArray`](type.ArcArray.html) for the array type!*
14041404
#[derive(Debug)]
1405-
pub struct OwnedArcRepr<A>(Arc<Vec<A>>);
1405+
pub struct OwnedArcRepr<A>(Arc<OwnedRepr<A>>);
14061406

14071407
impl<A> Clone for OwnedArcRepr<A> {
14081408
fn clone(&self) -> Self {

0 commit comments

Comments
 (0)