For got to mention that we have macros for those few times where you cannot
avoid a branch conditional. They are the LIKELY() and UNLIKELY() macros
provided by the common.h header. When you know some conditional will nearly
always be true or false 99% of the time, that's when LIKELY() or UNLIKELY()
should be used.
They basically add a compiler hint that tells the compiler's branch prediction
optimizations which code path to optimize for so there's less likely a chance
of a branch prediction penalty. They're the next best thing.
if (UNLIKELY(x < 0)) {
/* ... rare ... */
} else {
/* ... common ... */
}
Cheers!
Sean
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
BRL-CAD Developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-devel