[PATCH] Wrap the DEBUG checks in a "unlikely"

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Dec 28 07:49:01 GMT 2007


On Fri, Dec 28, 2007 at 07:51:08AM +0100, Stefan (metze) Metzmacher wrote:
> >  #define DEBUGADDC( dbgc_class, level, body ) \
> >    (void)( ((level) <= MAX_DEBUG_LEVEL) && \
> > -          ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
> > +          unlikely((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
> >             (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
> >              DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level))  ) \
> >         && (dbgtext body) )
> 
> wouldn't it make sense to put the whole logic into the unlikely?
> 
>     (void)(unlikely( ((level) <= MAX_DEBUG_LEVEL) && \
>             ((DEBUGLEVEL_CLASS[ dbgc_class ] >= (level))||  \
>              (!DEBUGLEVEL_CLASS_ISSET[ dbgc_class ] && \
>               DEBUGLEVEL_CLASS[ DBGC_ALL   ] >= (level)) )) \
>            && (dbgtest body) )

No, I don't think so. ((level) <= MAX_DEBUG_LEVEL) only sees
constants. A compiler not able to optimize away a if (1<100)
is probably too stupid to know about unlikely.

Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20071228/2a5b772b/attachment.bin


More information about the samba-technical mailing list