All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Kent Overstreet <kent.overstreet@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1] lib/generic-radix-tree: Make good use of while (level--)
Date: Thu, 21 Mar 2019 17:36:47 +0200	[thread overview]
Message-ID: <CAHp75VekmW1T4nsp+wtOKbc8Xf_aUGUwxAw6PrpSpYEubxbNEQ@mail.gmail.com> (raw)
In-Reply-To: <20190321153036.43084-1-andriy.shevchenko@linux.intel.com>

On Thu, Mar 21, 2019 at 5:32 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> There is no need to split postincrement in while (level--) type of loops.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  lib/generic-radix-tree.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/lib/generic-radix-tree.c b/lib/generic-radix-tree.c
> index a7bafc413730..5a1818a0de1f 100644
> --- a/lib/generic-radix-tree.c
> +++ b/lib/generic-radix-tree.c
> @@ -59,13 +59,9 @@ void *__genradix_ptr(struct __genradix *radix, size_t offset)
>         if (ilog2(offset) >= genradix_depth_shift(level))
>                 return NULL;
>
> -       while (1) {
> +       while (level--) {
>                 if (!n)
>                         return NULL;
> -               if (!level)
> -                       break;
> -
> -               level--;

My bad, this will need an additional check. before the loop.

>
>                 n = n->children[offset >> genradix_depth_shift(level)];
>                 offset &= genradix_depth_size(level) - 1;
> @@ -157,9 +153,7 @@ void *__genradix_iter_peek(struct genradix_iter *iter,
>         if (ilog2(iter->offset) >= genradix_depth_shift(level))
>                 return NULL;
>
> -       while (level) {
> -               level--;
> -
> +       while (level--) {
>                 i = (iter->offset >> genradix_depth_shift(level)) &
>                         (GENRADIX_ARY - 1);
>
> --
> 2.20.1
>


-- 
With Best Regards,
Andy Shevchenko

      reply	other threads:[~2019-03-21 15:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 15:30 [PATCH v1] lib/generic-radix-tree: Make good use of while (level--) Andy Shevchenko
2019-03-21 15:36 ` Andy Shevchenko [this message]

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=CAHp75VekmW1T4nsp+wtOKbc8Xf_aUGUwxAw6PrpSpYEubxbNEQ@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 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.