use branch hints in macros of slicing work-around
authorStefan Behnel <scoder@users.berlios.de>
Mon, 1 Nov 2010 18:39:48 +0000 (19:39 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Mon, 1 Nov 2010 18:39:48 +0000 (19:39 +0100)
Cython/Compiler/ModuleNode.py

index e00ccd07406e03e8bcfdec2c7570c31b94903ec1..6cf3b176ac4086e89696b6dbf8204ba9b9b3d4dc 100644 (file)
@@ -598,17 +598,17 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
   #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
   #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
 #else
-  #define __Pyx_PySequence_GetSlice(obj, a, b) ((!(obj)) ? \\
+  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \\
         (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \\
-        (((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \\
+        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \\
             (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
-  #define __Pyx_PySequence_SetSlice(obj, a, b, value) ((!(obj)) ? \\
+  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \\
         (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \\
-        (((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \\
+        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \\
             (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
-  #define __Pyx_PySequence_DelSlice(obj, a, b) ((!(obj)) ? \\
+  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \\
         (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \\
-        (((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \\
+        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \\
             (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
 #endif