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
82af1c0f
Commit
82af1c0f
authored
Dec 28, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
split argument default value assignment to avoid redundant reassignments
parent
0511e504
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+19
-9
No files found.
Cython/Compiler/Nodes.py
View file @
82af1c0f
...
@@ -1850,10 +1850,6 @@ class DefNode(FuncDefNode):
...
@@ -1850,10 +1850,6 @@ class DefNode(FuncDefNode):
arg_entry
=
arg
.
entry
arg_entry
=
arg
.
entry
if
arg
.
is_generic
:
if
arg
.
is_generic
:
if
arg
.
default
:
if
arg
.
default
:
code
.
putln
(
"%s = %s;"
%
(
arg_entry
.
cname
,
arg
.
default_result_code
))
default_seen
=
1
default_seen
=
1
if
not
arg
.
is_self_arg
:
if
not
arg
.
is_self_arg
:
if
arg
.
kw_only
:
if
arg
.
kw_only
:
...
@@ -2021,16 +2017,17 @@ class DefNode(FuncDefNode):
...
@@ -2021,16 +2017,17 @@ class DefNode(FuncDefNode):
elif
min_positional_args
==
max_positional_args
:
elif
min_positional_args
==
max_positional_args
:
# parse the exact number of positional arguments from the
# parse the exact number of positional arguments from the
# args tuple
# args tuple
if
max_positional_args
>
0
:
code
.
putln
(
'} else {'
)
code
.
putln
(
'} else {'
)
for
i
,
arg
in
enumerate
(
positional_args
):
for
i
,
arg
in
enumerate
(
positional_args
):
item
=
"PyTuple_GET_ITEM(%s, %d)"
%
(
Naming
.
args_cname
,
i
)
item
=
"PyTuple_GET_ITEM(%s, %d)"
%
(
Naming
.
args_cname
,
i
)
self
.
generate_arg_assignment
(
arg
,
item
,
code
)
self
.
generate_arg_assignment
(
arg
,
item
,
code
)
self
.
generate_arg_default_assignments
(
code
)
else
:
else
:
# parse the positional arguments from the variable length
# parse the positional arguments from the variable length
# args tuple
# args tuple
code
.
putln
(
'} else {'
)
code
.
putln
(
'} else {'
)
self
.
generate_arg_default_assignments
(
code
)
code
.
putln
(
'switch (PyTuple_GET_SIZE(%s)) {'
%
Naming
.
args_cname
)
code
.
putln
(
'switch (PyTuple_GET_SIZE(%s)) {'
%
Naming
.
args_cname
)
if
self
.
star_arg
:
if
self
.
star_arg
:
code
.
putln
(
'default:'
)
code
.
putln
(
'default:'
)
...
@@ -2067,6 +2064,14 @@ class DefNode(FuncDefNode):
...
@@ -2067,6 +2064,14 @@ class DefNode(FuncDefNode):
Naming
.
args_cname
))
Naming
.
args_cname
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
def
generate_arg_default_assignments
(
self
,
code
):
for
arg
in
self
.
args
:
if
arg
.
is_generic
and
arg
.
default
:
code
.
putln
(
"%s = %s;"
%
(
arg
.
entry
.
cname
,
arg
.
default_result_code
))
def
generate_stararg_init_code
(
self
,
max_positional_args
,
code
):
def
generate_stararg_init_code
(
self
,
max_positional_args
,
code
):
if
self
.
starstar_arg
:
if
self
.
starstar_arg
:
self
.
starstar_arg
.
entry
.
xdecref_cleanup
=
0
self
.
starstar_arg
.
entry
.
xdecref_cleanup
=
0
...
@@ -2202,6 +2207,11 @@ class DefNode(FuncDefNode):
...
@@ -2202,6 +2207,11 @@ class DefNode(FuncDefNode):
code
.
putln
(
"if (values[%d]) {"
%
i
)
code
.
putln
(
"if (values[%d]) {"
%
i
)
self
.
generate_arg_assignment
(
arg
,
"values[%d]"
%
i
,
code
)
self
.
generate_arg_assignment
(
arg
,
"values[%d]"
%
i
,
code
)
if
arg
.
default
and
not
arg
.
type
.
is_pyobject
:
if
arg
.
default
and
not
arg
.
type
.
is_pyobject
:
code
.
putln
(
'} else {'
)
code
.
putln
(
"%s = %s;"
%
(
arg
.
entry
.
cname
,
arg
.
default_result_code
))
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
def
generate_argument_conversion_code
(
self
,
code
):
def
generate_argument_conversion_code
(
self
,
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