{
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);
return obj;
}
-void bt_put(void *obj)
+void bt_put(void *ptr)
{
- if (obj) {
- struct bt_object *base = obj;
+ struct bt_object *obj = ptr;
- bt_ref_put(&base->ref_count);
+ if (unlikely(!obj)) {
+ return;
}
+
+ bt_ref_put(&obj->ref_count);
}