Add branch prediction hints in ref count interface
[babeltrace.git] / lib / ref.c
index ac0580137a5ad959d25fbfa29b3a3dc0a7ffae19..4e245adf583092ebcb95edb3b1dfc5dfd692b73f 100644 (file)
--- a/lib/ref.c
+++ b/lib/ref.c
@@ -31,11 +31,11 @@ void *bt_get(void *ptr)
 {
        struct bt_object *obj = ptr;
 
-       if (!obj) {
+       if (unlikely(!obj)) {
                goto end;
        }
 
-       if (obj->parent && bt_object_get_ref_count(obj) == 0) {
+       if (unlikely(obj->parent && bt_object_get_ref_count(obj) == 0)) {
                bt_get(obj->parent);
        }
        bt_ref_get(&obj->ref_count);
@@ -47,7 +47,7 @@ void bt_put(void *ptr)
 {
        struct bt_object *obj = ptr;
 
-       if (!obj) {
+       if (unlikely(!obj)) {
                return;
        }
 
This page took 0.025962 seconds and 4 git commands to generate.