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
20f67300
Commit
20f67300
authored
May 12, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix constant value check in switch statement generation
parent
ff46004a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+5
-3
No files found.
Cython/Compiler/Optimize.py
View file @
20f67300
...
...
@@ -867,7 +867,7 @@ class SwitchTransform(Visitor.VisitorTransform):
# duplicated values don't work in a switch statement
seen
=
set
()
for
value
in
condition_values
:
if
value
.
constant_result
is
not
ExprNodes
.
not_a_constant
:
if
value
.
has_constant_result
()
:
if
value
.
constant_result
in
seen
:
return
True
seen
.
add
(
value
.
constant_result
)
...
...
@@ -890,10 +890,12 @@ class SwitchTransform(Visitor.VisitorTransform):
conditions
=
conditions
,
body
=
if_clause
.
body
))
if
sum
([
len
(
case
.
conditions
)
for
case
in
cases
])
<
2
:
condition_values
=
[
cond
for
case
in
cases
for
cond
in
case
.
conditions
]
if
len
(
condition_values
)
<
2
:
self
.
visitchildren
(
node
)
return
node
if
self
.
has_duplicate_values
(
sum
([
case
.
conditions
for
case
in
cases
],
[])
):
if
self
.
has_duplicate_values
(
condition_values
):
self
.
visitchildren
(
node
)
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