simplification for iter-dict optimisation after moving TupleNode to new-style temp...
authorStefan Behnel <scoder@users.berlios.de>
Thu, 27 Nov 2008 13:30:21 +0000 (14:30 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 27 Nov 2008 13:30:21 +0000 (14:30 +0100)
Cython/Compiler/Optimize.py

index 3a3d7dcc2ba2785f8936bde8193a3673b267e1a2..c587bbd598376efaffea490a8e5ec48b0ca8206f 100644 (file)
@@ -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(