lkml.org 
[lkml]   [2003]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH][RFC] radix-tree.c
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...

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:33    [W:0.189 / U:1.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site