* [PATCH v2] btrfs: eliminate if in main loop in tree_search_offset
@ 2021-11-23 7:23 Nikolay Borisov
2021-11-23 14:30 ` Josef Bacik
2021-11-23 15:03 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Nikolay Borisov @ 2021-11-23 7:23 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.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
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(-)
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 145a07b19359..c5ee980e7a5e 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -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) {
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] btrfs: eliminate if in main loop in tree_search_offset
2021-11-23 7:23 [PATCH v2] btrfs: eliminate if in main loop in tree_search_offset Nikolay Borisov
@ 2021-11-23 14:30 ` Josef Bacik
2021-11-23 15:03 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Josef Bacik @ 2021-11-23 14:30 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Tue, Nov 23, 2021 at 09:23:42AM +0200, Nikolay Borisov wrote:
> 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 <nborisov@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Thanks,
Josef
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] btrfs: eliminate if in main loop in tree_search_offset
2021-11-23 7:23 [PATCH v2] btrfs: eliminate if in main loop in tree_search_offset Nikolay Borisov
2021-11-23 14:30 ` Josef Bacik
@ 2021-11-23 15:03 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2021-11-23 15:03 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs
On Tue, Nov 23, 2021 at 09:23:42AM +0200, Nikolay Borisov wrote:
> 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 <nborisov@suse.com>
> ---
> V2:
> * Set entry to NULL by default so that semantics is unchanged.
Added to misc-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-11-23 15:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-23 7:23 [PATCH v2] btrfs: eliminate if in main loop in tree_search_offset Nikolay Borisov
2021-11-23 14:30 ` Josef Bacik
2021-11-23 15:03 ` David Sterba
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.