diff options
author | Stefan Behnel <stefan_ml@behnel.de> | 2013-02-25 19:16:21 +0100 |
---|---|---|
committer | Stefan Behnel <stefan_ml@behnel.de> | 2013-02-25 19:16:21 +0100 |
commit | 5baf5330104f4809b6a37dbc502fb9e19b9f692f (patch) | |
tree | b6511674d23b223540d64476c5a166e9cb90b73f /Cython/Compiler/ModuleNode.py | |
parent | 199b5c5cbb7c1cf87436406035c3f2d2eceb3a4d (diff) | |
download | cython-5baf5330104f4809b6a37dbc502fb9e19b9f692f.tar.gz |
use a couple of branch prediction macros in tp_new() function, just in case
--HG--
extra : rebase_source : 32ab400fc7cf381d2267ae01b3ada7065d706ed2
Diffstat (limited to 'Cython/Compiler/ModuleNode.py')
-rw-r--r-- | Cython/Compiler/ModuleNode.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index b67721086..775da8d1c 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -1079,7 +1079,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.globalstate.use_utility_code( UtilityCode.load_cached("IncludeStringH", "StringTools.c")) obj_struct = type.declaration_code("", deref=True) - code.putln("if ((%s > 0) & (t->tp_basicsize == sizeof(%s))) {" % ( + code.putln("if (likely((%s > 0) & (t->tp_basicsize == sizeof(%s)))) {" % ( freecount_name, obj_struct)) code.putln("o = (PyObject*)%s[--%s];" % ( freelist_name, freecount_name)) @@ -1089,7 +1089,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("PyObject_GC_Track(o);") code.putln("} else {") code.putln("o = (*t->tp_alloc)(t, 0);") - code.putln("if (!o) return 0;") + code.putln("if (unlikely(!o)) return 0;") if freelist_size and not base_type: code.putln('}') if need_self_cast: @@ -1135,7 +1135,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): else: cinit_args = "o, a, k" code.putln( - "if (%s(%s) < 0) {" % + "if (unlikely(%s(%s) < 0)) {" % (new_func_entry.func_cname, cinit_args)) code.put_decref_clear("o", py_object_type, nanny=False) code.putln( |