code simplification
authorStefan Behnel <scoder@users.berlios.de>
Sun, 7 Dec 2008 11:15:33 +0000 (12:15 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sun, 7 Dec 2008 11:15:33 +0000 (12:15 +0100)
Cython/Compiler/Optimize.py

index 8978b8f41e86f31537d56655c5ffbff1f6003414..d59b5765d62c7ad9fecc1cf1eaabe66fa1d0be16 100644 (file)
@@ -314,41 +314,41 @@ class FlattenInListTransform(Visitor.VisitorTransform, SkipDeclarations):
         else:
             return node
 
-        if isinstance(node.operand2, ExprNodes.TupleNode) or isinstance(node.operand2, ExprNodes.ListNode):
-            args = node.operand2.args
-            if len(args) == 0:
-                return ExprNodes.BoolNode(pos = node.pos, value = node.operator == 'not_in')
+        if not isinstance(node.operand2, (ExprNodes.TupleNode, ExprNodes.ListNode)):
+            return node
 
-            if node.operand1.is_simple():
-                lhs = node.operand1
-            else:
-                # FIXME: allocate temp for evaluated node.operand1
-                return node
+        args = node.operand2.args
+        if len(args) == 0:
+            return ExprNodes.BoolNode(pos = node.pos, value = node.operator == 'not_in')
 
-            conds = []
-            for arg in args:
-                cond = ExprNodes.PrimaryCmpNode(
-                                    pos = node.pos,
-                                    operand1 = lhs,
-                                    operator = eq_or_neq,
-                                    operand2 = arg,
-                                    cascade = None)
-                conds.append(ExprNodes.TypecastNode(
-                                    pos = node.pos, 
-                                    operand = cond,
-                                    type = PyrexTypes.c_bint_type))
-                if type(lhs) is not ExprNodes.CloneNode:
-                    lhs = ExprNodes.CloneNode(lhs)
-            def concat(left, right):
-                return ExprNodes.BoolBinopNode(
-                                    pos = node.pos, 
-                                    operator = conjunction,
-                                    operand1 = left,
-                                    operand2 = right)
-
-            return reduce(concat, conds)
+        if True or node.operand1.is_simple():
+            lhs = node.operand1
         else:
+            # FIXME: allocate temp for evaluated node.operand1
             return node
+
+        conds = []
+        for arg in args:
+            cond = ExprNodes.PrimaryCmpNode(
+                                pos = node.pos,
+                                operand1 = lhs,
+                                operator = eq_or_neq,
+                                operand2 = arg,
+                                cascade = None)
+            conds.append(ExprNodes.TypecastNode(
+                                pos = node.pos, 
+                                operand = cond,
+                                type = PyrexTypes.c_bint_type))
+            if type(lhs) is not ExprNodes.CloneNode:
+                lhs = ExprNodes.CloneNode(lhs)
+        def concat(left, right):
+            return ExprNodes.BoolBinopNode(
+                                pos = node.pos, 
+                                operator = conjunction,
+                                operand1 = left,
+                                operand2 = right)
+
+        return reduce(concat, conds)
         
     def visit_Node(self, node):
         self.visitchildren(node)