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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
54345353
Commit
54345353
authored
Feb 17, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor duplicate code.
parent
06edacba
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
15 deletions
+10
-15
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+10
-15
No files found.
Cython/Compiler/ExprNodes.py
View file @
54345353
...
...
@@ -7866,26 +7866,21 @@ class TupleNode(SequenceNode):
if
len
(
self
.
args
)
==
0
:
# result_code is Naming.empty_tuple
return
if
self
.
is_partly_literal
:
# underlying tuple is const, but factor is not
if
self
.
is_literal
or
self
.
is_partly_literal
:
tuple_target
=
code
.
get_py_const
(
py_object_type
,
'tuple'
,
cleanup_level
=
2
)
const_code
=
code
.
get_cached_constants_writer
()
const_code
.
mark_pos
(
self
.
pos
)
self
.
generate_sequence_packing_code
(
const_code
,
tuple_target
,
plain
=
True
)
self
.
generate_sequence_packing_code
(
const_code
,
tuple_target
,
plain
=
not
self
.
is_literal
)
const_code
.
put_giveref
(
tuple_target
)
code
.
putln
(
'%s = PyNumber_Multiply(%s, %s); %s'
%
(
self
.
result
(),
tuple_target
,
self
.
mult_factor
.
py_result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)
if
self
.
is_literal
:
self
.
result_code
=
tuple_target
else
:
code
.
putln
(
'%s = PyNumber_Multiply(%s, %s); %s'
%
(
self
.
result
(),
tuple_target
,
self
.
mult_factor
.
py_result
(),
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)
))
code
.
put_gotref
(
self
.
py_result
())
elif
self
.
is_literal
:
# non-empty cached tuple => result is global constant,
# creation code goes into separate code writer
self
.
result_code
=
code
.
get_py_const
(
py_object_type
,
'tuple'
,
cleanup_level
=
2
)
code
=
code
.
get_cached_constants_writer
()
code
.
mark_pos
(
self
.
pos
)
self
.
generate_sequence_packing_code
(
code
)
code
.
put_giveref
(
self
.
py_result
())
code
.
put_gotref
(
self
.
py_result
())
else
:
self
.
type
.
entry
.
used
=
True
self
.
generate_sequence_packing_code
(
code
)
...
...
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