svn commit: r223884 - head/sys/sys
Ed Schouten
ed at 80386.nl
Sat Jul 9 15:36:30 UTC 2011
Hi Kostik,
* Konstantin Belousov <kib at FreeBSD.org>, 20110709 16:29:
> +static __inline uint16_t
> +bitcount16(uint32_t x)
Shouldn't we use uint16_t for the argument here?
When I saw the code, I thought by myself, this could be done more
efficiently:
| static __inline uint16_t
| bitcount16(uint16_t x)
| {
|
| x = (x & 0x5555) + ((x >> 1) & 0x5555);
| x = (x & 0x3333) + ((x >> 2) & 0x3333);
| x *= 0x1111;
| return (x >> 12);
| }
But some testing revealed it works for all inputs, except 65536. d'oh!
--
Ed Schouten <ed at 80386.nl>
WWW: http://80386.nl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-all/attachments/20110709/c7750fe4/attachment.pgp
More information about the svn-src-all
mailing list