summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2014-06-03 12:28:56 -0600
committerCharles Harris <charlesr.harris@gmail.com>2014-06-03 12:28:56 -0600
commit3f5e45737361e97a87c7652eac5e095729360994 (patch)
tree4dafb899e9df08aff579bda05a14a20fdfc682f0
parent14cc7172d78fb7cabbddcf7805c634ec0555abca (diff)
parente75e930c93ec55bf338c196f699d10fe3ed8aab1 (diff)
downloadnumpy-3f5e45737361e97a87c7652eac5e095729360994.tar.gz
Merge pull request #4772 from juliantaylor/scope-red
MAINT: reduce scope of some variables in indexing code
-rw-r--r--numpy/core/src/multiarray/lowlevel_strided_loops.c.src18
1 files changed, 8 insertions, 10 deletions
diff --git a/numpy/core/src/multiarray/lowlevel_strided_loops.c.src b/numpy/core/src/multiarray/lowlevel_strided_loops.c.src
index 4a75e3293..b9063273f 100644
--- a/numpy/core/src/multiarray/lowlevel_strided_loops.c.src
+++ b/numpy/core/src/multiarray/lowlevel_strided_loops.c.src
@@ -1374,12 +1374,11 @@ NPY_NO_EXPORT int
mapiter_trivial_@name@(PyArrayObject *self, PyArrayObject *ind,
PyArrayObject *result)
{
- char *base_ptr, *self_ptr, *ind_ptr, *result_ptr;
+ char *base_ptr, *ind_ptr, *result_ptr;
npy_intp self_stride, ind_stride, result_stride;
npy_intp fancy_dim = PyArray_DIM(self, 0);
npy_intp itersize;
- npy_intp indval;
int is_aligned = PyArray_ISALIGNED(self) && PyArray_ISALIGNED(result);
int needs_api = PyDataType_REFCHK(PyArray_DESCR(self));
@@ -1400,7 +1399,7 @@ mapiter_trivial_@name@(PyArrayObject *self, PyArrayObject *ind,
#if !@isget@
/* Check the indices beforehand */
while (itersize--) {
- indval = *((npy_intp*)ind_ptr);
+ npy_intp indval = *((npy_intp*)ind_ptr);
if (check_and_adjust_index(&indval, fancy_dim, 1, _save) < 0 ) {
return -1;
}
@@ -1429,8 +1428,9 @@ mapiter_trivial_@name@(PyArrayObject *self, PyArrayObject *ind,
default:
#endif
while (itersize--) {
+ char * self_ptr;
+ npy_intp indval = *((npy_intp*)ind_ptr);
assert(npy_is_aligned(ind_ptr, _ALIGN(npy_intp)));
- indval = *((npy_intp*)ind_ptr);
#if @isget@
if (check_and_adjust_index(&indval, fancy_dim, 1, _save) < 0 ) {
return -1;
@@ -1482,9 +1482,7 @@ NPY_NO_EXPORT int
mapiter_@name@(PyArrayMapIterObject *mit)
{
npy_intp *counter, count;
- npy_intp indval;
int i, is_aligned;
- char *self_ptr;
/* Cached mit info */
int numiter = mit->numiter;
@@ -1570,11 +1568,11 @@ mapiter_@name@(PyArrayMapIterObject *mit)
#endif
count = *counter;
while (count--) {
- self_ptr = baseoffset;
+ char * self_ptr = baseoffset;
for (i=0; i < @numiter@; i++) {
+ npy_intp indval = *((npy_intp*)outer_ptrs[i]);
assert(npy_is_aligned(outer_ptrs[i],
_ALIGN(npy_intp)));
- indval = *((npy_intp*)outer_ptrs[i]);
#if @isget@ && @one_iter@
if (check_and_adjust_index(&indval, fancy_dims[i],
@@ -1683,9 +1681,9 @@ mapiter_@name@(PyArrayMapIterObject *mit)
/* Outer iteration (safe because mit->size != 0) */
do {
- self_ptr = baseoffset;
+ char * self_ptr = baseoffset;
for (i=0; i < @numiter@; i++) {
- indval = *((npy_intp*)outer_ptrs[i]);
+ npy_intp indval = *((npy_intp*)outer_ptrs[i]);
#if @isget@ && @one_iter@
if (check_and_adjust_index(&indval, fancy_dims[i],