[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6026B6EA1@saturn3.aculab.com>
Date: Tue, 13 Mar 2012 16:55:14 -0000
From: "David Laight" <David.Laight@...LAB.COM>
To: "David Laight" <David.Laight@...LAB.COM>,
"Maciej Zenczykowski" <zenczykowski@...il.com>,
"Maciej Zenczykowski" <maze@...gle.com>
Cc: <netdev@...r.kernel.org>
Subject: RE: [PATCH] net: pfifo_fast - use ffs(x)-1 instead of array lookup
> > + /* 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
--
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