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
24322dc3
Commit
24322dc3
authored
Sep 26, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid generating redundant labels and gotos in boolean and/or expressions
parent
1442b569
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
+12
-8
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+12
-8
No files found.
Cython/Compiler/ExprNodes.py
View file @
24322dc3
...
...
@@ -9921,7 +9921,7 @@ class BoolBinopNode(ExprNode):
operator
=
self
.
operator
,
operand1
=
operand1
,
operand2
=
operand2
)
def
generate_bool_evaluation_code
(
self
,
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
):
def
generate_bool_evaluation_code
(
self
,
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
,
fall_through
):
code
.
mark_pos
(
self
.
pos
)
outer_labels
=
(
and_label
,
or_label
)
...
...
@@ -9929,18 +9929,20 @@ class BoolBinopNode(ExprNode):
my_label
=
and_label
=
code
.
new_label
(
'next_and'
)
else
:
my_label
=
or_label
=
code
.
new_label
(
'next_or'
)
self
.
operand1
.
generate_bool_evaluation_code
(
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
)
self
.
operand1
.
generate_bool_evaluation_code
(
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
,
my_label
)
and_label
,
or_label
=
outer_labels
code
.
put_label
(
my_label
)
self
.
operand2
.
generate_bool_evaluation_code
(
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
)
self
.
operand2
.
generate_bool_evaluation_code
(
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
,
fall_through
)
def
generate_evaluation_code
(
self
,
code
):
self
.
allocate_temp_result
(
code
)
or_label
=
and_label
=
None
end_label
=
code
.
new_label
(
'bool_binop_done'
)
self
.
generate_bool_evaluation_code
(
code
,
self
.
result
(),
and_label
,
or_label
,
end_label
)
self
.
generate_bool_evaluation_code
(
code
,
self
.
result
(),
and_label
,
or_label
,
end_label
,
end_label
)
code
.
put_label
(
end_label
)
gil_message
=
"Truth-testing Python object"
...
...
@@ -10025,7 +10027,7 @@ class BoolBinopResultNode(ExprNode):
test_result
=
self
.
arg
.
result
()
return
(
test_result
,
self
.
arg
.
type
.
is_pyobject
)
def
generate_bool_evaluation_code
(
self
,
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
):
def
generate_bool_evaluation_code
(
self
,
code
,
final_result_temp
,
and_label
,
or_label
,
end_label
,
fall_through
):
code
.
mark_pos
(
self
.
pos
)
# x => x
...
...
@@ -10045,10 +10047,12 @@ class BoolBinopResultNode(ExprNode):
if
or_label
:
# value is false => short-circuit to next 'or'
if
or_label
!=
fall_through
:
code
.
put_goto
(
or_label
)
code
.
putln
(
"} else {"
)
if
and_label
:
# value is true => go to next 'and'
if
and_label
!=
fall_through
:
code
.
put_goto
(
and_label
)
if
not
or_label
:
code
.
putln
(
"} else {"
)
...
...
@@ -10061,7 +10065,7 @@ class BoolBinopResultNode(ExprNode):
self
.
value
.
generate_post_assignment_code
(
code
)
self
.
arg
.
generate_disposal_code
(
code
)
self
.
value
.
free_temps
(
code
)
if
and_label
or
or_label
:
if
end_label
!=
fall_through
:
code
.
put_goto
(
end_label
)
if
and_label
or
or_label
:
...
...
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