Re: [PATCH][RFC] radix-tree.c

Andrew Morton (akpm@digeo.com)
Fri, 14 Feb 2003 15:01:28 -0800


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/