IB/rxe: Avoid NULL check when search is successful

While performing lookup in a pool, if entry is found, take the
reference right there, instead of checking again outside the loop and
save one branch.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Daniel Jurgens <danielj@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
Parav Pandit 2018-08-27 08:44:16 +03:00 committed by Doug Ledford
parent 3ccf19e25a
commit 536a631d1e

View file

@ -450,13 +450,12 @@ void *rxe_pool_get_index(struct rxe_pool *pool, u32 index)
node = node->rb_left;
else if (elem->index < index)
node = node->rb_right;
else
else {
kref_get(&elem->ref_cnt);
break;
}
}
if (node)
kref_get(&elem->ref_cnt);
out:
read_unlock_irqrestore(&pool->pool_lock, flags);
return node ? elem : NULL;