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): ...@@ -2055,9 +2055,13 @@ class DefNode(FuncDefNode):
code.putln('}') code.putln('}')
# now fill up the required arguments with values from the kw dict # now fill up the required arguments with values from the kw dict
code.putln('switch (PyTuple_GET_SIZE(%s)) {' % Naming.args_cname) last_required_arg = -1
needs_break = False
for i, arg in enumerate(all_args): 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 i <= max_positional_args:
if self.star_arg and i == max_positional_args: if self.star_arg and i == max_positional_args:
code.putln('default:') code.putln('default:')
...@@ -2065,10 +2069,7 @@ class DefNode(FuncDefNode): ...@@ -2065,10 +2069,7 @@ class DefNode(FuncDefNode):
code.putln('case %2d:' % i) code.putln('case %2d:' % i)
if arg.default: if arg.default:
# handled in ParseOptionalKeywords() below # handled in ParseOptionalKeywords() below
needs_break = True
continue continue
else:
needs_break = False
code.putln('values[%d] = PyDict_GetItem(%s, %s);' % ( code.putln('values[%d] = PyDict_GetItem(%s, %s);' % (
i, Naming.kwds_cname, arg.name_entry.pystring_cname)) i, Naming.kwds_cname, arg.name_entry.pystring_cname))
if i < min_positional_args: if i < min_positional_args:
...@@ -2095,8 +2096,6 @@ class DefNode(FuncDefNode): ...@@ -2095,8 +2096,6 @@ class DefNode(FuncDefNode):
self.name.utf8encode(), arg.name_entry.pystring_cname)) self.name.utf8encode(), arg.name_entry.pystring_cname))
code.putln(code.error_goto(self.pos)) code.putln(code.error_goto(self.pos))
code.putln('}') code.putln('}')
if needs_break:
code.putln('break;')
code.putln('}') code.putln('}')
code.putln('if (unlikely(kw_args > 0)) {') 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