mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@digeo.com>
To: Szabolcs Berecz <szabi@mplayerhq.hu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH][RFC] radix-tree.c
Date: Fri, 14 Feb 2003 15:01:28 -0800	[thread overview]
Message-ID: <20030214150128.5a28e7d5.akpm@digeo.com> (raw)
In-Reply-To: <Pine.LNX.4.33.0302142233370.16839-100000@mail.mplayerhq.hu>

Szabolcs Berecz <szabi@mplayerhq.hu> wrote:
>
> 
> With the following patch maxindex is taken from an array instead of
> recalculating it all the time.

Looks good to me.

> +static unsigned long height_to_maxindex[RADIX_TREE_MAX_PATH];
> +
>  /*
>   * Radix tree node cache.
>   */
> @@ -126,12 +128,9 @@
>   */
>  static inline unsigned long radix_tree_maxindex(unsigned int height)
>  {
> -	unsigned int tmp = height * RADIX_TREE_MAP_SHIFT;
> -	unsigned long index = (~0UL >> (RADIX_TREE_INDEX_BITS - tmp - 1)) >> 1;
> -
> -	if (tmp >= RADIX_TREE_INDEX_BITS)
> -		index = ~0UL;
> -	return index;
> +	if (unlikely(height >= RADIX_TREE_MAX_PATH))
> +		return ~0UL;
> +	return height_to_maxindex[height];

If you make height_to_maxindex[] a bit bigger, and fill it up with ~0UL's,
this comparison can be removed too.

I rather hope that height cannot be larger than RADIX_TREE_MAX_PATH anyway...


  reply	other threads:[~2003-02-14 22:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-14 21:35 Szabolcs Berecz
2003-02-14 23:01 ` Andrew Morton [this message]
2003-02-15  0:00   ` Szabolcs Berecz

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=20030214150128.5a28e7d5.akpm@digeo.com \
    --to=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=szabi@mplayerhq.hu \
    /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

all inboxes | Powered by JetHome®