[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANP3RGe6zQzsuvZ=qpcWFou6EY99HhWq0ekf6UkfqKCvj+eiRA@mail.gmail.com>
Date: Tue, 13 Mar 2012 13:37:25 -0700
From: Maciej Żenczykowski <maze@...gle.com>
To: David Laight <David.Laight@...lab.com>
Cc: netdev@...r.kernel.org
Subject: Re: [PATCH] net: pfifo_fast - use ffs(x)-1 instead of array lookup
but a 16-bit constant will be better than a 32-bit one on 16-bit platforms
On Tue, Mar 13, 2012 at 9:55 AM, David Laight <David.Laight@...lab.com> wrote:
>
>> > + /* For i in 0..7 returns {-1, 0, 1, 0, 2, 0, 1, 0}[i] */
>> > + return ((26468 >> (i+i)) & 3) - 1;
>>
>> That expression doesn't seem quite right to me ...
>> return (int)(0x12131210 >> (i * 4)) & 3) - 1;
>> probably does what is wanted.
>
> Hmmm... I'm going blind - I read that as 'i+1' not 'i+i'.
> But using 'i * 4' and putting the constant in base 16
> make the code rather less obscure.
>
> David
>
>
--
Maciej A. Żenczykowski
Kernel Networking Developer @ Google
1600 Amphitheatre Parkway, Mountain View, CA 94043
tel: +1 (650) 253-0062
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists