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
Xavier Thompson
cython
Commits
bd25a02e
Commit
bd25a02e
authored
Sep 23, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve handling of cpp iteration over directly accessible sequences
parent
189f4d85
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+11
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
bd25a02e
...
@@ -2974,14 +2974,14 @@ class CppIteratorNode(ExprNode):
...
@@ -2974,14 +2974,14 @@ class CppIteratorNode(ExprNode):
code
.
putln
(
"++%s;"
%
self
.
result
())
code
.
putln
(
"++%s;"
%
self
.
result
())
def
generate_subexpr_disposal_code
(
self
,
code
):
def
generate_subexpr_disposal_code
(
self
,
code
):
if
self
.
sequence
.
is_simple
()
:
if
not
self
.
cpp_sequence_cname
:
# the sequence is accessed directly so any temporary result in its
# the sequence is accessed directly so any temporary result in its
# subexpressions must remain available until the iterator is not needed
# subexpressions must remain available until the iterator is not needed
return
return
ExprNode
.
generate_subexpr_disposal_code
(
self
,
code
)
ExprNode
.
generate_subexpr_disposal_code
(
self
,
code
)
def
free_subexpr_temps
(
self
,
code
):
def
free_subexpr_temps
(
self
,
code
):
if
self
.
sequence
.
is_simple
()
:
if
not
self
.
cpp_sequence_cname
:
# the sequence is accessed directly so any temporary result in its
# the sequence is accessed directly so any temporary result in its
# subexpressions must remain available until the iterator is not needed
# subexpressions must remain available until the iterator is not needed
return
return
...
@@ -2996,11 +2996,19 @@ class CppIteratorNode(ExprNode):
...
@@ -2996,11 +2996,19 @@ class CppIteratorNode(ExprNode):
self
.
cpp_attribute_op
))
self
.
cpp_attribute_op
))
if
self
.
cpp_sequence_cname
and
self
.
sequence
.
type
.
is_cyp_class
:
if
self
.
cpp_sequence_cname
and
self
.
sequence
.
type
.
is_cyp_class
:
code
.
put_decref
(
self
.
cpp_sequence_cname
,
self
.
sequence
.
type
)
code
.
put_decref
(
self
.
cpp_sequence_cname
,
self
.
sequence
.
type
)
if
self
.
sequence
.
is_simple
()
:
if
not
self
.
cpp_sequence_cname
:
# postponed from CppIteratorNode.generate_subexpr_disposal_code
# postponed from CppIteratorNode.generate_subexpr_disposal_code
# and CppIteratorNode.free_subexpr_temps
# and CppIteratorNode.free_subexpr_temps
ExprNode
.
generate_subexpr_disposal_code
(
self
,
code
)
ExprNode
.
generate_subexpr_disposal_code
(
self
,
code
)
ExprNode
.
free_subexpr_temps
(
self
,
code
)
ExprNode
.
free_subexpr_temps
(
self
,
code
)
# Adapt relevant bits from ExprNode.generate_disposal_code
if
self
.
result
()
and
not
self
.
has_temp_moved
and
self
.
type
.
is_cyp_class
:
code
.
put_xdecref_clear
(
self
.
result
(),
self
.
ctype
(),
have_gil
=
not
self
.
in_nogil_context
)
if
self
.
has_temp_moved
:
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"MoveIfSupported"
,
"CppSupport.cpp"
))
else
:
ExprNode
.
generate_disposal_code
(
self
,
code
)
def
free_temps
(
self
,
code
):
def
free_temps
(
self
,
code
):
if
self
.
cpp_sequence_cname
:
if
self
.
cpp_sequence_cname
:
...
...
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