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
Boxiang Sun
cython
Commits
44a8c73d
Commit
44a8c73d
authored
Jul 15, 2008
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor fix for switch node.
parent
858476d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+2
-0
tests/run/switch.pyx
tests/run/switch.pyx
+10
-10
No files found.
Cython/Compiler/Optimize.py
View file @
44a8c73d
...
...
@@ -71,6 +71,8 @@ class SwitchTransform(Visitor.VisitorTransform):
cases
.
append
(
Nodes
.
SwitchCaseNode
(
pos
=
if_clause
.
pos
,
conditions
=
conditions
,
body
=
if_clause
.
body
))
common_var
=
unwrap_node
(
common_var
)
return
Nodes
.
SwitchStatNode
(
pos
=
node
.
pos
,
test
=
common_var
,
cases
=
cases
,
...
...
tests/run/switch.pyx
View file @
44a8c73d
...
...
@@ -25,9 +25,9 @@ __doc__ = u"""
>>> switch_py(8)
4
>>> switch_py(10)
7
10
>>> switch_py(12)
8
12
>>> switch_py(13)
0
...
...
@@ -57,9 +57,9 @@ __doc__ = u"""
>>> switch_c(8)
4
>>> switch_c(10)
7
10
>>> switch_c(12)
8
12
>>> switch_c(13)
0
"""
...
...
@@ -86,10 +86,10 @@ def switch_py(x):
return
3
elif
x
in
[
4
,
5
,
7
,
8
]:
return
4
elif
x
in
(
10
,
11
):
# doesn't work: (7,8,10,11)
return
7
elif
x
in
(
10
,
11
):
return
10
elif
x
in
(
12
,):
return
8
return
12
else
:
return
0
return
-
1
...
...
@@ -116,10 +116,10 @@ def switch_c(int x):
return
3
elif
x
in
[
4
,
5
,
7
,
8
]:
return
4
elif
x
in
(
10
,
11
):
# doesn't work: (7,8,10,11)
return
7
elif
x
in
(
10
,
11
):
return
10
elif
x
in
(
12
,):
return
8
return
12
else
:
return
0
return
-
1
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