From: Nikolay Borisov Date: Tue, 23 Nov 2021 07:23:42 +0000 (+0200) Subject: btrfs: eliminate if in main loop in tree_search_offset X-Git-Tag: block-5.17-2022-01-21~54^2~82 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=f1a8fc626586fcc62dd7eb44ebeddb4517784015;p=linux-2.6-block.git 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. Reviewed-by: Josef Bacik Signed-off-by: Nikolay Borisov Signed-off-by: David Sterba --- diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index bbe0b36a452a..a45017b12185 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c @@ -1636,15 +1636,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; @@ -1654,6 +1649,8 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl, n = n->rb_right; else break; + + entry = NULL; } if (bitmap_only) {