On Tue, Jul 03, 2012 at 02:03:39AM +0000, Dave Hart wrote:
> On Tue, Jul 3, 2012 at 01:49 UTC, Michael W. Bombardieri <m...@ii.net> wrote:
> > Sorry, my fault. The intent was bitwise-and not bitwise-or.
> > Third version of the diff follows.
> > In regards to hand optimisations, we could be even worse
> > and do something like add rn_id values, subtract rn_len, check
> > if zero. :)
> 
> I don't understand why you don't simply write the obvious comparison
> of each to 1 for equality, anding them together logically, and let the
> compiler play the bit-twiddling games.  Bitwise and will be correct, I
> believe, but obfuscated in a place where micro-optimization seems
> pointless.  The same goes for the add then subtract alternative.

I automatically typed the bitwise code, either because it seems somehow
simpler, or because it's marginally less typing. Something like the
following might be easier for people to read. I don't have a strong
opinion on this in any case.

#define RCSNUM_ISDEFBRANCH(n) \
        ((n)->rn_len == 3 && (n)->rn_id[0] == 1 \
        && (n)->rn_id[1] == 1 && (n)->rn_id[2] == 1)

> 
> Cheers,
> Dave Hart

Reply via email to