Commit 57d4d305 authored by Stefan Behnel's avatar Stefan Behnel

avoid generating inlined keyword unpacking code when signature has only optional arguments

parent 4cd97c23
......@@ -2055,9 +2055,13 @@ class DefNode(FuncDefNode):
code.putln('}')
# now fill up the required arguments with values from the kw dict
code.putln('switch (PyTuple_GET_SIZE(%s)) {' % Naming.args_cname)
needs_break = False
last_required_arg = -1
for i, arg in enumerate(all_args):
if not arg.default:
last_required_arg = i
if last_required_arg >= 0:
code.putln('switch (PyTuple_GET_SIZE(%s)) {' % Naming.args_cname)
for i, arg in enumerate(all_args[:last_required_arg+1]):
if i <= max_positional_args:
if self.star_arg and i == max_positional_args:
code.putln('default:')
......@@ -2065,10 +2069,7 @@ class DefNode(FuncDefNode):
code.putln('case %2d:' % i)
if arg.default:
# handled in ParseOptionalKeywords() below
needs_break = True
continue
else:
needs_break = False
code.putln('values[%d] = PyDict_GetItem(%s, %s);' % (
i, Naming.kwds_cname, arg.name_entry.pystring_cname))
if i < min_positional_args:
......@@ -2095,8 +2096,6 @@ class DefNode(FuncDefNode):
self.name.utf8encode(), arg.name_entry.pystring_cname))
code.putln(code.error_goto(self.pos))
code.putln('}')
if needs_break:
code.putln('break;')
code.putln('}')
code.putln('if (unlikely(kw_args > 0)) {')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment