From dc38b785170bd4651d3797bab1980d731145af85 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Thu, 27 Nov 2008 14:30:21 +0100 Subject: [PATCH] simplification for iter-dict optimisation after moving TupleNode to new-style temp usage --- Cython/Compiler/Optimize.py | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/Cython/Compiler/Optimize.py b/Cython/Compiler/Optimize.py index 3a3d7dcc..c587bbd5 100644 --- a/Cython/Compiler/Optimize.py +++ b/Cython/Compiler/Optimize.py @@ -142,27 +142,17 @@ class DictIterTransform(Visitor.VisitorTransform): stats = [node.body]) if tuple_target: - temp = UtilNodes.TempHandle(Builtin.tuple_type) - temp.needs_cleanup = False # assignment steals the reference - temp_tuple = temp.ref(tuple_target.pos) - class TempTupleNode(ExprNodes.TupleNode): - # FIXME: remove this after result-code refactoring - def result(self): - return temp_tuple.result() - - tuple_result = TempTupleNode( + tuple_result = ExprNodes.TupleNode( pos = tuple_target.pos, args = [key_temp, value_temp], is_temp = 1, type = Builtin.tuple_type, ) body.stats.insert( - 0, UtilNodes.TempsBlockNode( - tuple_target.pos, temps = [temp], - body = Nodes.SingleAssignmentNode( - pos = tuple_target.pos, - lhs = tuple_target, - rhs = tuple_result))) + 0, Nodes.SingleAssignmentNode( + pos = tuple_target.pos, + lhs = tuple_target, + rhs = tuple_result)) else: # execute all coercions before the assignments coercion_stats = [] @@ -190,14 +180,14 @@ class DictIterTransform(Visitor.VisitorTransform): body.stats[0:0] = coercion_stats + assign_stats result_code = [ - Nodes.SingleAssignmentNode( - pos = node.pos, - lhs = pos_temp, - rhs = ExprNodes.IntNode(node.pos, value=0)), Nodes.SingleAssignmentNode( pos = dict_obj.pos, lhs = dict_temp, rhs = dict_obj), + Nodes.SingleAssignmentNode( + pos = node.pos, + lhs = pos_temp, + rhs = ExprNodes.IntNode(node.pos, value=0)), Nodes.WhileStatNode( pos = node.pos, condition = ExprNodes.SimpleCallNode( -- 2.26.2