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
5b182356
Commit
5b182356
authored
Mar 23, 2016
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use standard node dispatch mechanism instead of explicit type tests in transform
parent
3b1277a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+7
-6
No files found.
Cython/Compiler/Optimize.py
View file @
5b182356
...
...
@@ -3952,6 +3952,12 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
sequence_node
.
mult_factor
=
factor
return
sequence_node
def
visit_FormattedValueNode
(
self
,
node
):
self
.
visitchildren
(
node
)
if
isinstance
(
node
.
format_spec
,
ExprNodes
.
UnicodeNode
)
and
not
node
.
format_spec
.
value
:
node
.
format_spec
=
None
return
node
def
visit_JoinedStrNode
(
self
,
node
):
"""
Clean up after the parser by discarding empty Unicode strings and merging
...
...
@@ -3960,7 +3966,6 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
"""
self
.
visitchildren
(
node
)
unicode_node
=
ExprNodes
.
UnicodeNode
format_node
=
ExprNodes
.
FormattedValueNode
values
=
[]
for
is_unode_group
,
substrings
in
itertools
.
groupby
(
node
.
values
,
lambda
v
:
isinstance
(
v
,
unicode_node
)):
...
...
@@ -3973,11 +3978,7 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
if
unode
.
value
:
values
.
append
(
unode
)
else
:
for
value
in
substrings
:
if
isinstance
(
value
,
format_node
):
if
isinstance
(
value
.
format_spec
,
unicode_node
)
and
not
value
.
format_spec
.
value
:
value
.
format_spec
=
None
values
.
append
(
value
)
values
.
extend
(
substrings
)
if
not
values
:
node
=
ExprNodes
.
UnicodeNode
(
node
.
pos
,
value
=
EncodedString
(
''
))
...
...
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