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
Gwenaël Samain
cython
Commits
08c1d574
Commit
08c1d574
authored
Dec 01, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify some code
parent
60428dd9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
15 deletions
+8
-15
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+0
-6
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+8
-9
No files found.
Cython/Compiler/Nodes.py
View file @
08c1d574
...
...
@@ -5328,12 +5328,6 @@ class IfClauseNode(Node):
self
.
body
=
self
.
body
.
analyse_expressions
(
env
)
return
self
def
get_constant_condition_result
(
self
):
if
self
.
condition
.
has_constant_result
():
return
bool
(
self
.
condition
.
constant_result
)
else
:
return
None
def
generate_execution_code
(
self
,
code
,
end_label
):
self
.
condition
.
generate_evaluation_code
(
code
)
code
.
putln
(
...
...
Cython/Compiler/Optimize.py
View file @
08c1d574
...
...
@@ -3306,17 +3306,16 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
# eliminate dead code based on constant condition results
if_clauses
=
[]
for
if_clause
in
node
.
if_clauses
:
condition_result
=
if_clause
.
get_constant_condition_result
()
if
condition_result
is
None
:
# unknown result => normal runtime evaluation
if_clauses
.
append
(
if_clause
)
elif
condition_result
==
True
:
# subsequent clauses can safely be dropped
condition
=
if_clause
.
condition
if
condition
.
has_constant_result
():
if
condition
.
constant_result
:
# always true => subsequent clauses can safely be dropped
node
.
else_clause
=
if_clause
.
body
break
# else: false => drop clause
else
:
#
False clauses can safely be deleted
assert
condition_result
==
False
#
unknown result => normal runtime evaluation
if_clauses
.
append
(
if_clause
)
if
if_clauses
:
node
.
if_clauses
=
if_clauses
return
node
...
...
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