public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: eliminate if in main loop in tree_search_offset
@ 2021-11-22 15:17 Nikolay Borisov
  2021-11-22 16:50 ` Josef Bacik
  0 siblings, 1 reply; 3+ messages in thread
From: Nikolay Borisov @ 2021-11-22 15:17 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Nikolay Borisov

Reshuffle the code inside the first loop of tree_search_offset so that
one if() is eliminated and the becomes more linear.
---
 fs/btrfs/free-space-cache.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 145a07b19359..141fae2692a4 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1595,12 +1595,7 @@ tree_search_offset(struct btrfs_free_space_ctl *ctl,
 	struct btrfs_free_space *entry, *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) {
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-23  6:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-22 15:17 [PATCH] btrfs: eliminate if in main loop in tree_search_offset Nikolay Borisov
2021-11-22 16:50 ` Josef Bacik
2021-11-23  6:50   ` Nikolay Borisov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox