On Fri, May 31, 2013 6:36 am, Marko Mäkelä wrote: > On Fri, May 31, 2013 at 12:18:03PM +0300, Marko Mäkelä wrote: >>If this is at least a 16-bit system, you could also assign the two >>bytes to an integer, invert it and write code like this (I guess you >>can keep the loop unrolled): >> >>unsigned mask = (1 << 10) - 1; >> >>if (!(b & mask)) break; >>mask <<= 1; >>if (!(b & mask)) break; >>... > > I realized an even better way: > > const unsigned mask = (1 << 10) - 1; > > if (!(b & mask)) break; > b >>= 1; > if (!(b & mask)) break; > b >>= 1; > ... Yes, this is the elegant way. Similar is done in the weak bit searching/handling. -Pete Message was sent through the cbm-hackers mailing listReceived on 2013-05-31 13:00:04
Archive generated by hypermail 2.2.0.