void bt_ref_get(struct bt_ref *ref)
{
assert(ref);
- if (ref->release) {
- /* Object has opted-in reference counting. */
- ref->count++;
- /* Overflow check. */
- assert(ref->count);
+
+ if (unlikely(!ref->release)) {
+ return;
}
+
+ ref->count++;
+ /* Overflow check. */
+ assert(ref->count);
}
static inline
{
assert(ref);
/* Only assert if the object has opted-in for reference counting. */
- if ((--ref->count) == 0 && ref->release) {
+ if (unlikely((--ref->count) == 0 && ref->release)) {
ref->release((struct bt_object *) ref);
}
}