bcachefs: minor bch2_btree_path_set_pos() optimization
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 8 Dec 2023 06:51:04 +0000 (01:51 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 1 Jan 2024 16:47:43 +0000 (11:47 -0500)
bpos_eq() is cheaper than bpos_cmp()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_iter.c
fs/bcachefs/btree_iter.h

index 79e6ec7b9a5271b4964d73c1bcfcf41de8e9b054..f16fefbb64977b4068047764528e9918d2039142 100644 (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);
 
index 29f02335642e9c1684e5593446d046439c17c584..3b981144e4722600be0aee0c952ef2608efa49d6 100644 (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;
 }