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
6ca2b4a9
Commit
6ca2b4a9
authored
Jan 11, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify some code, add some comments
parent
5297e74b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
12 deletions
+8
-12
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+8
-12
No files found.
Cython/Compiler/Optimize.py
View file @
6ca2b4a9
...
...
@@ -632,8 +632,7 @@ class IterationTransform(Visitor.EnvTransform):
if
len
(
args
)
<
3
:
step_pos
=
range_function
.
pos
step_value
=
1
step
=
ExprNodes
.
IntNode
(
step_pos
,
value
=
'1'
,
constant_result
=
1
)
step
=
ExprNodes
.
IntNode
(
step_pos
,
value
=
'1'
,
constant_result
=
1
)
else
:
step
=
args
[
2
]
step_pos
=
step
.
pos
...
...
@@ -664,6 +663,7 @@ class IterationTransform(Visitor.EnvTransform):
if
abs_step
!=
1
:
if
(
isinstance
(
bound1
.
constant_result
,
(
int
,
long
))
and
isinstance
(
bound2
.
constant_result
,
(
int
,
long
))):
# calculate final bounds now
if
step_value
<
0
:
begin_value
=
bound2
.
constant_result
end_value
=
bound1
.
constant_result
...
...
@@ -677,6 +677,7 @@ class IterationTransform(Visitor.EnvTransform):
bound1
.
pos
,
value
=
str
(
bound1_value
),
constant_result
=
bound1_value
,
type
=
PyrexTypes
.
spanning_type
(
bound1
.
type
,
bound2
.
type
))
else
:
# evaluate the same expression as above at runtime
bound2_ref_node
=
UtilNodes
.
LetRefNode
(
bound2
)
spanning_type
=
PyrexTypes
.
spanning_type
(
bound1
.
type
,
bound2
.
type
)
spanning_step_type
=
PyrexTypes
.
spanning_type
(
spanning_type
,
step
.
type
)
...
...
@@ -685,19 +686,17 @@ class IterationTransform(Visitor.EnvTransform):
begin_value
=
bound2_ref_node
end_value
=
bound1
final_op
=
'-'
final_node
=
ExprNodes
.
SubNode
else
:
begin_value
=
bound1
end_value
=
bound2_ref_node
final_op
=
'+'
final_node
=
ExprNodes
.
AddNode
bound1
=
final
_node
(
bound1
=
ExprNodes
.
binop
_node
(
bound1
.
pos
,
operand1
=
final
_node
(
operand1
=
ExprNodes
.
binop
_node
(
bound1
.
pos
,
operand1
=
bound2_ref_node
,
operator
=
final_op
,
operator
=
final_op
,
# +/-
operand2
=
ExprNodes
.
MulNode
(
bound1
.
pos
,
operand1
=
ExprNodes
.
IntNode
(
...
...
@@ -731,7 +730,7 @@ class IterationTransform(Visitor.EnvTransform):
type
=
spanning_step_type
),
type
=
spanning_step_type
),
type
=
spanning_step_type
),
operator
=
final_op
,
operator
=
final_op
,
# +/-
operand2
=
ExprNodes
.
IntNode
(
bound1
.
pos
,
value
=
'1'
,
...
...
@@ -747,10 +746,7 @@ class IterationTransform(Visitor.EnvTransform):
if
not
bound2
.
is_literal
:
# stop bound must be immutable => keep it in a temp var
bound2_is_temp
=
True
if
bound2_ref_node
:
bound2
=
bound2_ref_node
else
:
bound2
=
UtilNodes
.
LetRefNode
(
bound2
)
bound2
=
bound2_ref_node
or
UtilNodes
.
LetRefNode
(
bound2
)
else
:
bound2_is_temp
=
False
...
...
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