Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
66b81226
Commit
66b81226
authored
Dec 31, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent creation of "suboffset_dim" temp when it's not used in memory view slicing code
parent
f0d60728
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
13 deletions
+17
-13
Cython/Compiler/MemoryView.py
Cython/Compiler/MemoryView.py
+13
-9
Cython/Utility/MemoryView_C.c
Cython/Utility/MemoryView_C.c
+4
-4
No files found.
Cython/Compiler/MemoryView.py
View file @
66b81226
...
...
@@ -288,7 +288,6 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
Simply call __pyx_memoryview_slice_memviewslice with the right
arguments.
"""
new_ndim
=
0
src
=
self
.
cname
def
load_slice_util
(
name
,
context_dict
):
...
...
@@ -296,17 +295,22 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
name
,
"MemoryView_C.c"
,
context
=
context_dict
)
return
impl
all_dimensions_direct
=
all
(
access
==
'direct'
for
access
,
packing
in
self
.
type
.
axes
)
no_suboffset_dim
=
all_dimensions_direct
and
not
have_slices
if
not
no_suboffset_dim
:
suboffset_dim
=
code
.
funcstate
.
allocate_temp
(
PyrexTypes
.
c_int_type
,
manage_ref
=
False
)
code
.
putln
(
"%s = -1;"
%
suboffset_dim
)
code
.
putln
(
"%(dst)s.data = %(src)s.data;"
%
locals
())
code
.
putln
(
"%(dst)s.memview = %(src)s.memview;"
%
locals
())
code
.
put_incref_memoryviewslice
(
dst
)
all_dimensions_direct
=
all
(
access
==
'direct'
for
access
,
packing
in
self
.
type
.
axes
)
suboffset_dim_temp
=
[]
def
get_suboffset_dim
():
if
not
suboffset_dim_temp
:
suboffset_dim
=
code
.
funcstate
.
allocate_temp
(
PyrexTypes
.
c_int_type
,
manage_ref
=
False
)
code
.
putln
(
"%s = -1;"
%
suboffset_dim
)
suboffset_dim_temp
.
append
(
suboffset_dim
)
return
suboffset_dim_temp
[
0
]
dim
=
-
1
new_ndim
=
0
for
index
in
indices
:
if
index
.
is_none
:
# newaxis
...
...
@@ -356,8 +360,8 @@ class MemoryViewSliceBufferEntry(Buffer.BufferEntry):
)
code
.
put
(
load_slice_util
(
"SliceIndex"
,
d
))
if
not
no_suboffset_dim
:
code
.
funcstate
.
release_temp
(
suboffset_dim
)
if
suboffset_dim_temp
:
code
.
funcstate
.
release_temp
(
suboffset_dim
_temp
[
0
]
)
def
empty_slice
(
pos
):
...
...
Cython/Utility/MemoryView_C.c
View file @
66b81226
...
...
@@ -815,7 +815,7 @@ if (unlikely(__pyx_memoryview_slice_memviewslice(
{{
src
}}.
shape
[{{
dim
}}],
{{
src
}}.
strides
[{{
dim
}}],
{{
src
}}.
suboffsets
[{{
dim
}}],
{{
dim
}},
{{
new_ndim
}},
&
{{
suboffset_dim
}},
&
{{
get_suboffset_dim
()
}},
{{
start
}},
{{
stop
}},
{{
step
}},
...
...
@@ -840,7 +840,7 @@ if (unlikely(__pyx_memoryview_slice_memviewslice(
{{
else
}}
{{
dst
}}.
suboffsets
[{{
new_ndim
}}]
=
{{
src
}}.
suboffsets
[{{
dim
}}];
if
({{
src
}}.
suboffsets
[{{
dim
}}]
>=
0
)
{{
suboffset_dim
}}
=
{{
new_ndim
}};
{{
get_suboffset_dim
()
}}
=
{{
new_ndim
}};
{{
endif
}}
...
...
@@ -877,7 +877,7 @@ if (unlikely(__pyx_memoryview_slice_memviewslice(
{{
if
all_dimensions_direct
}}
{{
dst
}}.
data
+=
__pyx_tmp_idx
*
__pyx_tmp_stride
;
{{
else
}}
if
({{
suboffset_dim
}}
<
0
)
{
if
({{
get_suboffset_dim
()
}}
<
0
)
{
{{
dst
}}.
data
+=
__pyx_tmp_idx
*
__pyx_tmp_stride
;
/* This dimension is the first dimension, or is preceded by */
...
...
@@ -899,7 +899,7 @@ if (unlikely(__pyx_memoryview_slice_memviewslice(
{{
endif
}}
}
else
{
{{
dst
}}.
suboffsets
[{{
suboffset_dim
}}]
+=
__pyx_tmp_idx
*
__pyx_tmp_stride
;
{{
dst
}}.
suboffsets
[{{
get_suboffset_dim
()
}}]
+=
__pyx_tmp_idx
*
__pyx_tmp_stride
;
/* Note: dimension can not be indirect, the compiler will have */
/* issued an error */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment