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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
b80966c6
Commit
b80966c6
authored
Dec 29, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix evaluation of assignment order when considering DefNode calls for inlining
parent
5690000c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+13
-6
No files found.
Cython/Compiler/Optimize.py
View file @
b80966c6
...
@@ -1660,18 +1660,25 @@ class EarlyReplaceBuiltinCalls(Visitor.EnvTransform):
...
@@ -1660,18 +1660,25 @@ class EarlyReplaceBuiltinCalls(Visitor.EnvTransform):
class
InlineDefNodeCalls
(
Visitor
.
EnvTransform
):
class
InlineDefNodeCalls
(
Visitor
.
EnvTransform
):
visit_Node
=
Visitor
.
VisitorTransform
.
recurse_to_children
visit_Node
=
Visitor
.
VisitorTransform
.
recurse_to_children
def
get_constant_value_node
(
self
,
name_node
):
if
not
name_node
.
cf_state
or
not
name_node
.
cf_state
.
is_single
:
# no single assignment in the current scope
return
None
entry
=
self
.
current_env
().
lookup
(
name_node
.
name
)
if
not
entry
or
(
not
entry
.
cf_assignments
or
len
(
entry
.
cf_assignments
)
!=
1
):
# not just a single assignment in all closures
return
None
return
name_node
.
cf_state
.
one
().
rhs
def
visit_SimpleCallNode
(
self
,
node
):
def
visit_SimpleCallNode
(
self
,
node
):
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
if
not
self
.
current_directives
.
get
(
'optimize.inline_defnode_calls'
):
if
not
self
.
current_directives
.
get
(
'optimize.inline_defnode_calls'
):
return
node
return
node
function_name
=
node
.
function
function_name
=
node
.
function
if
not
function_name
.
is_name
or
function_name
.
cf_state
is
None
:
if
not
function_name
.
is_name
:
return
node
entry
=
self
.
current_env
().
lookup
(
function_name
.
name
)
if
not
entry
or
(
not
entry
.
cf_assignments
or
len
(
entry
.
cf_assignments
)
!=
1
):
return
node
return
node
function
=
entry
.
cf_assignments
[
0
].
rhs
function
=
self
.
get_constant_value_node
(
function_name
)
if
not
isinstance
(
function
,
ExprNodes
.
PyCFunctionNode
):
if
not
isinstance
(
function
,
ExprNodes
.
PyCFunctionNode
):
return
node
return
node
inlined
=
ExprNodes
.
InlinedDefNodeCallNode
(
inlined
=
ExprNodes
.
InlinedDefNodeCallNode
(
...
...
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