Commit 5ce8b92d authored by Kent Overstreet's avatar Kent Overstreet

bcachefs: minor bch2_btree_path_set_pos() optimization

bpos_eq() is cheaper than bpos_cmp()
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 4753bdeb
...@@ -1221,8 +1221,10 @@ struct btree_path *__bch2_btree_path_make_mut(struct btree_trans *trans, ...@@ -1221,8 +1221,10 @@ struct btree_path *__bch2_btree_path_make_mut(struct btree_trans *trans,
struct btree_path * __must_check struct btree_path * __must_check
__bch2_btree_path_set_pos(struct btree_trans *trans, __bch2_btree_path_set_pos(struct btree_trans *trans,
struct btree_path *path, struct bpos new_pos, 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); bch2_trans_verify_not_in_restart(trans);
EBUG_ON(!path->ref); EBUG_ON(!path->ref);
......
...@@ -176,17 +176,15 @@ bch2_btree_path_make_mut(struct btree_trans *trans, ...@@ -176,17 +176,15 @@ bch2_btree_path_make_mut(struct btree_trans *trans,
struct btree_path * __must_check struct btree_path * __must_check
__bch2_btree_path_set_pos(struct btree_trans *, struct btree_path *, __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 static inline struct btree_path * __must_check
bch2_btree_path_set_pos(struct btree_trans *trans, bch2_btree_path_set_pos(struct btree_trans *trans,
struct btree_path *path, struct bpos new_pos, struct btree_path *path, struct bpos new_pos,
bool intent, unsigned long ip) bool intent, unsigned long ip)
{ {
int cmp = bpos_cmp(new_pos, path->pos); return !bpos_eq(new_pos, path->pos)
? __bch2_btree_path_set_pos(trans, path, new_pos, intent, ip)
return cmp
? __bch2_btree_path_set_pos(trans, path, new_pos, intent, ip, cmp)
: path; : path;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment