summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Wieser <wieser.eric@gmail.com>2019-05-26 12:19:47 -0700
committerEric Wieser <wieser.eric@gmail.com>2019-06-01 13:44:55 -0700
commitd3c1c222292725d13190f73e23ec49e7b10e86cf (patch)
treeabd01fdaacf6da41fccea75204de9840aa8580f0
parent64edab687abce12c09b60ab78db2666738b37ef2 (diff)
downloadnumpy-d3c1c222292725d13190f73e23ec49e7b10e86cf.tar.gz
MAINT: remove unnecessary recomputation of is_empty
-rw-r--r--numpy/core/src/multiarray/item_selection.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/numpy/core/src/multiarray/item_selection.c b/numpy/core/src/multiarray/item_selection.c
index 63c6487bf..c2fa7cbfe 100644
--- a/numpy/core/src/multiarray/item_selection.c
+++ b/numpy/core/src/multiarray/item_selection.c
@@ -2207,8 +2207,6 @@ PyArray_Nonzero(PyArrayObject *self)
NpyIter_IterNextFunc *iternext;
NpyIter_GetMultiIndexFunc *get_multi_index;
char **dataptr;
- int is_empty = 0;
-
/* Special case - nonzero(zero_d) is nonzero(atleast1d(zero_d)) */
if (ndim == 0) {
@@ -2373,18 +2371,11 @@ finish:
return NULL;
}
- for (i = 0; i < PyArray_NDIM(ret); ++i) {
- if (PyArray_DIMS(ret)[i] == 0) {
- is_empty = 1;
- break;
- }
- }
-
/* Create views into ret, one for each dimension */
for (i = 0; i < ndim; ++i) {
npy_intp stride = ndim * NPY_SIZEOF_INTP;
/* the result is an empty array, the view must point to valid memory */
- npy_intp data_offset = is_empty ? 0 : i * NPY_SIZEOF_INTP;
+ npy_intp data_offset = nonzero_count == 0 ? 0 : i * NPY_SIZEOF_INTP;
PyArrayObject *view = (PyArrayObject *)PyArray_NewFromDescrAndBase(
Py_TYPE(ret), PyArray_DescrFromType(NPY_INTP),