Commit 6e4ccc8e authored by Robert Bradshaw's avatar Robert Bradshaw

Use wraparound and boundscheck directives for memory view slices.

parent 94a7d440
......@@ -3358,7 +3358,8 @@ class IndexNode(ExprNode):
buffer_entry.generate_buffer_slice_code(code, self.original_indices,
self.result(),
have_gil=have_gil,
have_slices=have_slices)
have_slices=have_slices,
directives=code.globalstate.directives)
def generate_memoryviewslice_setslice_code(self, rhs, code):
"memslice1[...] = memslice2 or memslice1[:] = memslice2"
......
......@@ -273,7 +273,7 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
return bufp
def generate_buffer_slice_code(self, code, indices, dst, have_gil,
have_slices):
have_slices, directives):
"""
Slice a memoryviewslice.
......@@ -359,6 +359,8 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
"All preceding dimensions must be "
"indexed and not sliced")
wraparound = int(directives['wraparound'])
boundscheck = int(directives['boundscheck'])
d = locals()
code.put(load_slice_util("SliceIndex", d))
......
......@@ -759,10 +759,10 @@ if (unlikely(__pyx_memoryview_slice_memviewslice(
Py_ssize_t __pyx_tmp_idx = {{idx}};
Py_ssize_t __pyx_tmp_shape = {{src}}.shape[{{dim}}];
Py_ssize_t __pyx_tmp_stride = {{src}}.strides[{{dim}}];
if (__pyx_tmp_idx < 0)
if ({{wraparound}} && (__pyx_tmp_idx < 0))
__pyx_tmp_idx += __pyx_tmp_shape;
if (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape) {
if ({{boundscheck}} && (__pyx_tmp_idx < 0 || __pyx_tmp_idx >= __pyx_tmp_shape)) {
{{if not have_gil}}
#ifdef WITH_THREAD
PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment