add UNLIKELY / LIKELY util defines to help optimize iterators that are called a lot, only defined for gcc at the moment.

also some cmake formatting edits.
This commit is contained in:
Campbell Barton
2011-12-29 01:46:58 +00:00
parent 2ca9a6a004
commit 85a97f64a7
5 changed files with 16 additions and 7 deletions

View File

@@ -300,4 +300,13 @@
# define BLI_assert(a) (void)0
#endif
/* hints for branch pradiction, only use in code that runs a _lot_ where */
#ifdef __GNUC__
# define LIKELY(x) __builtin_expect(!!(x), 1)
# define UNLIKELY(x) __builtin_expect(!!(x), 0)
#else
# define LIKELY(x) (x)
# define UNLIKELY(x) (x)
#endif
#endif // BLI_UTILDEFINES_H