Re: snag of G_LIKELY()



Am Sam, 2002-11-23 um 00.01 schrieb Matthias Clasen:
> On Fri, 2002-11-22 at 17:09, Daniel Elstner wrote:
> >  Also, there's no point in doing
> > 
> >     if (G_LIKELY (expr)) { } else
> > 
> > anymore since the empty if() branch was only there to trigger the GCC
> > warning in case of an assignment in the condition.
> 
> So should this be simplified to the following ?
> 
> #define G_LIKELY(expr) __builtin_expect (!(expr), 0)
> #define G_UNLIKELY(expr) __builtin_expect (!(expr), 1)

I think the double bang should stay there, unless you want to be flamed
by potential users of G_LIKELY who prefer plain boolean logic ;)

As for g_return_if_fail() and friends, I find Owen's idea to be quite
interesting.  Since G_LIKELY() requires gcc >= 3.0 anyway this shouldn't
be much of a problem, should it?

--Daniel





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]