minor code cleanup
authorStefan Behnel <stefan_ml@behnel.de>
Sat, 23 Feb 2013 10:35:53 +0000 (11:35 +0100)
committerStefan Behnel <stefan_ml@behnel.de>
Sat, 23 Feb 2013 10:35:53 +0000 (11:35 +0100)
Cython/Compiler/Optimize.py

index d888e40..f1391ca 100644 (file)
@@ -3011,13 +3011,13 @@ class ConstantFolding(Visitor.VisitorTransform, SkipDeclarations):
             return node
         if not node.operand.is_literal:
             return node
-        if isinstance(node, ExprNodes.NotNode):
-            return ExprNodes.BoolNode(node.pos, value = bool(node.constant_result),
-                                      constant_result = bool(node.constant_result))
+        if node.operator == '!':
+            return ExprNodes.BoolNode(node.pos, value=bool(node.constant_result),
+                                      constant_result=bool(node.constant_result))
         elif isinstance(node.operand, ExprNodes.BoolNode):
-            return ExprNodes.IntNode(node.pos, value = str(int(node.constant_result)),
-                                     type = PyrexTypes.c_int_type,
-                                     constant_result = int(node.constant_result))
+            return ExprNodes.IntNode(node.pos, value=str(int(node.constant_result)),
+                                     type=PyrexTypes.c_int_type,
+                                     constant_result=int(node.constant_result))
         elif node.operator == '+':
             return self._handle_UnaryPlusNode(node)
         elif node.operator == '-':