bcachefs: minor bch2_btree_path_set_pos() optimization

bpos_eq() is cheaper than bpos_cmp()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2023-12-08 01:51:04 -05:00
parent 4753bdeb26
commit 5ce8b92da0
2 changed files with 6 additions and 6 deletions

View File

@ -1221,8 +1221,10 @@ struct btree_path *__bch2_btree_path_make_mut(struct btree_trans *trans,
struct btree_path * __must_check
__bch2_btree_path_set_pos(struct btree_trans *trans,
struct btree_path *path, struct bpos new_pos,
bool intent, unsigned long ip, int cmp)
bool intent, unsigned long ip)
{
int cmp = bpos_cmp(new_pos, path->pos);
bch2_trans_verify_not_in_restart(trans);
EBUG_ON(!path->ref);

View File

@ -176,17 +176,15 @@ bch2_btree_path_make_mut(struct btree_trans *trans,
struct btree_path * __must_check
__bch2_btree_path_set_pos(struct btree_trans *, struct btree_path *,
struct bpos, bool, unsigned long, int);
struct bpos, bool, unsigned long);
static inline struct btree_path * __must_check
bch2_btree_path_set_pos(struct btree_trans *trans,
struct btree_path *path, struct bpos new_pos,
bool intent, unsigned long ip)
{
int cmp = bpos_cmp(new_pos, path->pos);
return cmp
? __bch2_btree_path_set_pos(trans, path, new_pos, intent, ip, cmp)
return !bpos_eq(new_pos, path->pos)
? __bch2_btree_path_set_pos(trans, path, new_pos, intent, ip)
: path;
}