code cleanup
authorStefan Behnel <scoder@users.berlios.de>
Mon, 22 Mar 2010 08:19:53 +0000 (09:19 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Mon, 22 Mar 2010 08:19:53 +0000 (09:19 +0100)
Cython/Compiler/Optimize.py

index 134538c79c113b4a6f324b93a04d2ee265ca869b..66be83933f784a32d63981a2a801fdc6f65b7db8 100644 (file)
@@ -967,10 +967,12 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
                 if node.type.assignable_from(arg.arg.type):
                     # completely redundant C->Py->C coercion
                     return arg.arg.coerce_to(node.type, self.env_stack[-1])
-        if not isinstance(arg, ExprNodes.SimpleCallNode):
-            return node
-        if not (node.type.is_int or node.type.is_float):
-            return node
+        if isinstance(arg, ExprNodes.SimpleCallNode):
+            if node.type.is_int or node.type.is_float:
+                return self._optimise_numeric_cast_call(node, arg)
+        return node
+
+    def _optimise_numeric_cast_call(self, node, arg):
         function = arg.function
         if not isinstance(function, ExprNodes.NameNode) \
                or not function.type.is_builtin_type \