Skip to content

Commit

Permalink
Avoid unnecessary generation of unused error handling code in memory …
Browse files Browse the repository at this point in the history
…view slicing code.
  • Loading branch information
scoder committed May 15, 2020
1 parent 399a72d commit 794d21d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 4 additions & 2 deletions Cython/Compiler/MemoryView.py
Expand Up @@ -292,7 +292,6 @@ def get_suboffset_dim():

dim += 1
access, packing = self.type.axes[dim]
error_goto = code.error_goto(index.pos)

if isinstance(index, ExprNodes.SliceNode):
# slice, unspecified dimension, or part of ellipsis
Expand All @@ -309,6 +308,7 @@ def get_suboffset_dim():
util_name = "SimpleSlice"
else:
util_name = "ToughSlice"
d['error_goto'] = code.error_goto(index.pos)

new_ndim += 1
else:
Expand All @@ -326,8 +326,10 @@ def get_suboffset_dim():
d = dict(
locals(),
wraparound=int(directives['wraparound']),
boundscheck=int(directives['boundscheck'])
boundscheck=int(directives['boundscheck']),
)
if d['boundscheck']:
d['error_goto'] = code.error_goto(index.pos)
util_name = "SliceIndex"

_, impl = TempitaUtilityCode.load_as_string(util_name, "MemoryView_C.c", context=d)
Expand Down
3 changes: 0 additions & 3 deletions Cython/Utility/MemoryView_C.c
Expand Up @@ -878,9 +878,6 @@ if (unlikely(__pyx_memoryview_slice_memviewslice(

{{error_goto}}
}
{{else}}
// make sure label is not un-used
if ((0)) {{error_goto}}
{{endif}}

{{if all_dimensions_direct}}
Expand Down

0 comments on commit 794d21d

Please sign in to comment.