diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-12-10 16:35:45 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-01 11:47:43 -0500 |
commit | 1f75ba4e65c54ff0517d7cd073afceb0751d1a32 (patch) | |
tree | 0f0fe37d0211a81157141d1a7d9054b23b94e7a8 /fs/bcachefs/btree_iter.h | |
parent | 7f9821a7c10bca1903bfa75126db199a40ec3b62 (diff) | |
download | linux-1f75ba4e65c54ff0517d7cd073afceb0751d1a32.tar.gz linux-1f75ba4e65c54ff0517d7cd073afceb0751d1a32.tar.bz2 linux-1f75ba4e65c54ff0517d7cd073afceb0751d1a32.zip |
bcachefs: struct trans_for_each_path_inorder_iter
reducing our usage of path->idx
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_iter.h')
-rw-r--r-- | fs/bcachefs/btree_iter.h | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/fs/bcachefs/btree_iter.h b/fs/bcachefs/btree_iter.h index e6ec971d66d3..a4d1d26c706d 100644 --- a/fs/bcachefs/btree_iter.h +++ b/fs/bcachefs/btree_iter.h @@ -125,10 +125,17 @@ static inline struct btree_path *prev_btree_path(struct btree_trans *trans, stru : NULL; } -#define trans_for_each_path_inorder(_trans, _path, _i) \ - for (_i = 0; \ - ((_path) = (_trans)->paths + trans->sorted[_i]), (_i) < (_trans)->nr_sorted;\ - _i++) +struct trans_for_each_path_inorder_iter { + btree_path_idx_t sorted_idx; + btree_path_idx_t path_idx; +}; + +#define trans_for_each_path_inorder(_trans, _path, _iter) \ + for (_iter = (struct trans_for_each_path_inorder_iter) { 0 }; \ + (_iter.path_idx = trans->sorted[_iter.sorted_idx], \ + _path = (_trans)->paths + _iter.path_idx, \ + _iter.sorted_idx < (_trans)->nr_sorted); \ + _iter.sorted_idx++) #define trans_for_each_path_inorder_reverse(_trans, _path, _i) \ for (_i = trans->nr_sorted - 1; \ |