From: Kent Overstreet Date: Wed, 23 Nov 2022 04:47:22 +0000 (-0500) Subject: bcachefs: Tiny bch2_trans_update_by_path_trace() optimization X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a2519a9688d3eeb6c4b2df3ab80b70e62458528d;p=linux.git bcachefs: Tiny bch2_trans_update_by_path_trace() optimization This just removes a redundant comparison - there's more work we could do here to remove some redundant copying. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c index 7029391496cbe..3782dd56088ff 100644 --- a/fs/bcachefs/btree_update_leaf.c +++ b/fs/bcachefs/btree_update_leaf.c @@ -1459,6 +1459,7 @@ bch2_trans_update_by_path_trace(struct btree_trans *trans, struct btree_path *pa { struct bch_fs *c = trans->c; struct btree_insert_entry *i, n; + int cmp; EBUG_ON(!path->should_be_locked); EBUG_ON(trans->nr_updates >= BTREE_ITER_MAX); @@ -1485,12 +1486,13 @@ bch2_trans_update_by_path_trace(struct btree_trans *trans, struct btree_path *pa * Pending updates are kept sorted: first, find position of new update, * then delete/trim any updates the new update overwrites: */ - trans_for_each_update(trans, i) - if (btree_insert_entry_cmp(&n, i) <= 0) + trans_for_each_update(trans, i) { + cmp = btree_insert_entry_cmp(&n, i); + if (cmp <= 0) break; + } - if (i < trans->updates + trans->nr_updates && - !btree_insert_entry_cmp(&n, i)) { + if (!cmp && i < trans->updates + trans->nr_updates) { EBUG_ON(i->insert_trigger_run || i->overwrite_trigger_run); bch2_path_put(trans, i->path, true);