Skip to content

Commit c35b5cd

Browse files
committed
Drop PyArray::copy_ptr is somewhat obscures what is happening at the call sites.
1 parent e933e27 commit c35b5cd

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/array.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,10 +356,6 @@ impl<T, D> PyArray<T, D> {
356356
let ptr = self.as_array_ptr();
357357
(*ptr).data as *mut _
358358
}
359-
360-
pub(crate) unsafe fn copy_ptr(&self, other: *const T, len: usize) {
361-
ptr::copy_nonoverlapping(other, self.data(), len)
362-
}
363359
}
364360

365361
struct InvertedAxes(u32);
@@ -959,7 +955,7 @@ impl<T: Element> PyArray<T, Ix1> {
959955
unsafe {
960956
let array = PyArray::new(py, [slice.len()], false);
961957
if T::IS_COPY {
962-
array.copy_ptr(slice.as_ptr(), slice.len());
958+
ptr::copy_nonoverlapping(slice.as_ptr(), array.data(), slice.len());
963959
} else {
964960
let data_ptr = array.data();
965961
for (i, item) in slice.iter().enumerate() {

src/convert.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Defines conversion traits between Rust types and NumPy data types.
22
#![deny(missing_docs)]
33

4-
use std::{mem, os::raw::c_int};
4+
use std::{mem, os::raw::c_int, ptr};
55

66
use ndarray::{ArrayBase, Data, Dimension, IntoDimension, Ix1, OwnedRepr};
77
use pyo3::Python;
@@ -143,12 +143,12 @@ where
143143
let len = self.len();
144144
match self.order() {
145145
Some(order) if A::IS_COPY => {
146-
// if the array is contiguous, copy it by `copy_ptr`.
146+
// if the array is contiguous, copy it by `copy_nonoverlapping`.
147147
let strides = self.npy_strides();
148148
unsafe {
149149
let array =
150150
PyArray::new_(py, self.raw_dim(), strides.as_ptr(), order.to_flag());
151-
array.copy_ptr(self.as_ptr(), len);
151+
ptr::copy_nonoverlapping(self.as_ptr(), array.data(), len);
152152
array
153153
}
154154
}

0 commit comments

Comments
 (0)