Commit 6f51454c authored by Stefan Behnel's avatar Stefan Behnel

prevent useless method call 'optimisation' for inner functions and classes

parent ba59a707
...@@ -4204,12 +4204,12 @@ class FinalOptimizePhase(Visitor.CythonTransform, Visitor.NodeRefCleanupMixin): ...@@ -4204,12 +4204,12 @@ class FinalOptimizePhase(Visitor.CythonTransform, Visitor.NodeRefCleanupMixin):
elif function.is_name: elif function.is_name:
if function.entry.is_builtin: if function.entry.is_builtin:
may_be_a_method = False may_be_a_method = False
elif function.cf_state: elif function.entry.cf_assignments:
# local functions/classes are definitely not methods # local functions/classes are definitely not methods
non_method_nodes = (ExprNodes.PyCFunctionNode, ExprNodes.ClassNode, ExprNodes.Py3ClassNode) non_method_nodes = (ExprNodes.PyCFunctionNode, ExprNodes.ClassNode, ExprNodes.Py3ClassNode)
may_be_a_method = any( may_be_a_method = any(
assignment.rhs and not isinstance(assignment.rhs, non_method_nodes) assignment.rhs and not isinstance(assignment.rhs, non_method_nodes)
for assignment in function.cf_state) for assignment in function.entry.cf_assignments)
if may_be_a_method: if may_be_a_method:
node = self.replace(node, ExprNodes.PyMethodCallNode.from_node( node = self.replace(node, ExprNodes.PyMethodCallNode.from_node(
node, function=function, arg_tuple=node.arg_tuple, type=node.type)) node, function=function, arg_tuple=node.arg_tuple, type=node.type))
......
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