[Mesa-dev] [PATCH] faster util_next_power_of_two() function

Benjamin b.bellec at gmail.com
Wed Jun 8 07:33:11 PDT 2011


2011/6/8 Chris Bandy <cbandy at jbandy.com>

> On 06/08/2011 06:38 AM, Benjamin Bellec wrote:
> > Here is the v4 patch.
> >
> > Benjamin
>
> As an uninformed bystander, I have some nitpicks that may just be coding
> style.
>
> From the patch:
>
> +   if (x <= 1)
> +       return 1;
>
>
> I think it would make more sense to move this above the #ifdef and not
> duplicate it in each implementation. It's about the function input, not
> the implementations.
>
I thought to that, but given that declaration must be before the code,
in the "gcc path" you will have the declaration of "val" which is not
used...
you will have a GCC warning.
Moreover, I think doing this slightly reduces the code readibility
(the two "path" would be imbricated).


>
> From the patch:
>
> +   else
> +       return (1 << ((sizeof(unsigned) * 8) - __builtin_clz(x - 1)));
>
>
> I don't like else after return. The else can be removed entirely.
>
> -- Chris
>
If you really really want, I can do a v5 patch ;-)

Benjamin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110608/6243bef0/attachment-0001.htm>


More information about the mesa-dev mailing list