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
600ee47d
Commit
600ee47d
authored
Dec 16, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small refactoring
parent
03715858
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
16 deletions
+17
-16
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+17
-16
No files found.
Cython/Compiler/Optimize.py
View file @
600ee47d
...
@@ -45,22 +45,24 @@ class DictIterTransform(Visitor.VisitorTransform):
...
@@ -45,22 +45,24 @@ class DictIterTransform(Visitor.VisitorTransform):
PyDict_Next_entry
=
Symtab
.
Entry
(
PyDict_Next_entry
=
Symtab
.
Entry
(
PyDict_Next_name
,
PyDict_Next_name
,
PyDict_Next_func_type
)
PyDict_Next_name
,
PyDict_Next_name
,
PyDict_Next_func_type
)
def
visit_Node
(
self
,
node
):
# descend into statements (loops) and nodes (comprehensions)
self
.
visitchildren
(
node
)
return
node
def
visit_ForInStatNode
(
self
,
node
):
def
visit_ForInStatNode
(
self
,
node
):
self
.
visitchildren
(
node
)
self
.
visitchildren
(
node
)
iterator
=
node
.
iterator
.
sequence
iterator
=
node
.
iterator
.
sequence
if
iterator
.
type
is
Builtin
.
dict_type
:
if
iterator
.
type
is
Builtin
.
dict_type
:
# like iterating over dict.keys()
# like iterating over dict.keys()
dict_obj
=
iterator
return
self
.
_transform_dict_iteration
(
keys
=
True
node
,
dict_obj
=
iterator
,
keys
=
True
,
values
=
False
)
values
=
False
else
:
if
not
isinstance
(
iterator
,
ExprNodes
.
SimpleCallNode
):
if
not
isinstance
(
iterator
,
ExprNodes
.
SimpleCallNode
):
return
node
return
node
function
=
iterator
.
function
function
=
iterator
.
function
if
not
isinstance
(
function
,
ExprNodes
.
AttributeNode
):
if
isinstance
(
function
,
ExprNodes
.
AttributeNode
)
and
\
return
node
function
.
obj
.
type
==
Builtin
.
dict_type
:
if
function
.
obj
.
type
!=
Builtin
.
dict_type
:
return
node
dict_obj
=
function
.
obj
dict_obj
=
function
.
obj
method
=
function
.
attribute
method
=
function
.
attribute
...
@@ -73,7 +75,11 @@ class DictIterTransform(Visitor.VisitorTransform):
...
@@ -73,7 +75,11 @@ class DictIterTransform(Visitor.VisitorTransform):
keys
=
values
=
True
keys
=
values
=
True
else
:
else
:
return
node
return
node
return
self
.
_transform_dict_iteration
(
node
,
dict_obj
,
keys
,
values
)
return
node
def
_transform_dict_iteration
(
self
,
node
,
dict_obj
,
keys
,
values
):
py_object_ptr
=
PyrexTypes
.
c_void_ptr_type
py_object_ptr
=
PyrexTypes
.
c_void_ptr_type
temps
=
[]
temps
=
[]
...
@@ -219,11 +225,6 @@ class DictIterTransform(Visitor.VisitorTransform):
...
@@ -219,11 +225,6 @@ class DictIterTransform(Visitor.VisitorTransform):
stats
=
result_code
stats
=
result_code
))
))
def
visit_Node
(
self
,
node
):
# descend into statements (loops) and nodes (comprehensions)
self
.
visitchildren
(
node
)
return
node
class
SwitchTransform
(
Visitor
.
VisitorTransform
):
class
SwitchTransform
(
Visitor
.
VisitorTransform
):
"""
"""
...
...
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