public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Nikolay Borisov <nborisov@suse.com>, Qu Wenruo <wqu@suse.com>,
	linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/3] btrfs: ctree: Reduce one indent level for btrfs_search_slot()
Date: Tue, 10 Sep 2019 16:31:21 +0800	[thread overview]
Message-ID: <cd8d32b6-77fa-6d7c-c610-00e126904375@gmx.com> (raw)
In-Reply-To: <c5db2dfd-19df-685c-71fb-e7e0e59a0b85@suse.com>



On 2019/9/10 下午4:24, Nikolay Borisov wrote:
>
>
> On 10.09.19 г. 10:40 ч., Qu Wenruo wrote:
>> In btrfs_search_slot(), we something like:
>>
>> 	if (level != 0) {
>> 		/* Do search inside tree nodes*/
>> 	} else {
>> 		/* Do search inside tree leaves */
>> 		goto done;
>> 	}
>>
>> This caused extra indent for tree node search code.
>> Change it to something like:
>>
>> 	if (level == 0) {
>> 		/* Do search inside tree leaves */
>> 		goto done'
>> 	}
>> 	/* Do search inside tree nodes */
>>
>> So we have more space to maneuver our code, this is especially useful as
>> the tree nodes search code is more complex than the leaves search code.
>>
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>
> I actually thing this patch makes comprehending the function worse.

If the level == 0 lines is over 50 lines, maybe.

But it's just 22 lines.
> Because the else is now somewhat implicit. E.g. one has to pay careful
> attention to the contents inside the first if and especially the
> unconditional 'goto done' to be able to understand the code after the
> 'if' construct.

That's the same for the original code, you need to go a level upper to
see we're in level > 0 branch.

Thanks,
Qu
>

  reply	other threads:[~2019-09-10  8:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-10  7:40 [PATCH 0/3] Small code style cleanup for ctree.c Qu Wenruo
2019-09-10  7:40 ` [PATCH 1/3] btrfs: ctree: Reduce one indent level for btrfs_search_slot() Qu Wenruo
2019-09-10  7:54   ` Anand Jain
2019-09-10  8:24   ` Nikolay Borisov
2019-09-10  8:31     ` Qu Wenruo [this message]
2019-09-10  8:42       ` Nikolay Borisov
2019-09-23 16:09         ` David Sterba
2019-09-10  7:40 ` [PATCH 2/3] btrfs: ctree: Reduce one indent level for btrfs_search_old_slot() Qu Wenruo
2019-09-10  7:58   ` Anand Jain
2019-09-23 16:32   ` David Sterba
2019-09-10  7:40 ` [PATCH 3/3] btrfs: ctree: Remove stalled comment of setting up path lock Qu Wenruo
2019-09-10  7:51   ` Nikolay Borisov
2019-09-23 16:36 ` [PATCH 0/3] Small code style cleanup for ctree.c David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cd8d32b6-77fa-6d7c-c610-00e126904375@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox