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
Kirill Smelkov
cython
Commits
cc8a670b
Commit
cc8a670b
authored
Dec 01, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
discard constant True condition in while loops
parent
ff18a041
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
1 deletion
+6
-1
Cython/Compiler/FlowControl.py
Cython/Compiler/FlowControl.py
+2
-1
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+1
-0
tests/run/constant_folding.py
tests/run/constant_folding.py
+3
-0
No files found.
Cython/Compiler/FlowControl.py
View file @
cc8a670b
...
...
@@ -904,6 +904,7 @@ class ControlFlowAnalysis(CythonTransform):
next_block
=
self
.
flow
.
newblock
()
# Condition block
self
.
flow
.
loops
.
append
(
LoopDescr
(
next_block
,
condition_block
))
if
node
.
condition
:
self
.
_visit
(
node
.
condition
)
# Body block
self
.
flow
.
nextblock
()
...
...
Cython/Compiler/Optimize.py
View file @
cc8a670b
...
...
@@ -3382,6 +3382,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
self
.
visitchildren
(
node
)
if
node
.
condition
.
has_constant_result
():
if
node
.
condition
.
constant_result
:
node
.
condition
=
None
node
.
else_clause
=
None
else
:
return
node
.
else_clause
...
...
tests/run/constant_folding.py
View file @
cc8a670b
...
...
@@ -192,6 +192,9 @@ def while_false_else():
@
cython
.
test_fail_if_path_exists
(
"//WhileStatNode//PrintStatNode"
,
"//WhileStatNode//PrimaryCmpNode"
,
"//WhileStatNode/BoolNode"
,
"//WhileStatNode/IntNode"
,
)
@
cython
.
test_assert_path_exists
(
"//WhileStatNode"
,
...
...
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