btrfs: eliminate if in main loop in tree_search_offset
PATCH v2 1/1 btrfs: eliminate if in main loop in tree_search_offset
Reshuffle the code inside the first loop of tree_search_offset so that one if() is eliminated and the becomes more linear.
Signed-off-by Nikolay Borisov <[email protected]>
---
V2:
* Set entry to NULL by default so that semantics is unchanged.
fs/btrfs/free-space-cache.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
fs/btrfs/free-space-cache.c +4 -7
@@ -1592,15 +1592,10 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl, u64 offset, int bitmap_only, int fuzzy) { struct rb_node *n = ctl->free_space_offset.rb_node; -struct btrfs_free_space *entry, *prev =NULL ; +struct btrfs_free_space *entry =NULL , *prev =NULL ;/* find entry that is closest to the 'offset' */ -while (1 ) { -if (!n) { - entry =NULL ; -break ; - } - +while (n) { entry = rb_entry(n, struct btrfs_free_space, offset_index); prev = entry;
@@ -1610,6 +1605,8 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl, n = n->rb_right; else break; + + entry =NULL ; }if (bitmap_only) {
Signature · 1 line
2.17.1
Quoted 4 lines · Nikolay Borisov
Reshuffle the code inside the first loop of
tree_search_offsetso that oneif()is eliminated and the becomes more linear.Signed-off-by Nikolay Borisov <[email protected]>
Reviewed-by Josef Bacik <[email protected]>
Thanks,
Josef
Quoted 7 lines · Nikolay Borisov
Reshuffle the code inside the first loop of
tree_search_offsetso that oneif()is eliminated and the becomes more linear.Signed-off-by Nikolay Borisov <[email protected]>---
V2:
* Set entry to NULL by default so that semantics is unchanged.
Added to misc-next, thanks.