diff options
author | Alberto Mardegan <mardy@users.sourceforge.net> | 2011-04-04 10:28:09 (GMT) |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@nokia.com> | 2011-04-04 10:44:22 (GMT) |
commit | 3290e4c1956bc6df63af669523391565c67e8c42 (patch) | |
tree | b6efbe424cd1a50097193dbad363f5cd1b7a2188 /src/corelib/global/qglobal.cpp | |
parent | 0cf75b4dd1cc25694de8ece4c25ecb97a3969a54 (diff) | |
download | Qt-3290e4c1956bc6df63af669523391565c67e8c42.zip Qt-3290e4c1956bc6df63af669523391565c67e8c42.tar.gz Qt-3290e4c1956bc6df63af669523391565c67e8c42.tar.bz2 |
Add branch prediction macros
This adds support for Q_LIKELY and Q_UNLIKELY macros which instruct the
compiler on which branch of an "if" statement is more likely to happen.
The current patch only supports GCC's __builtin_expect().
Merge-request: 2580
Reviewed-by: ossi
Diffstat (limited to 'src/corelib/global/qglobal.cpp')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 54b9d89..b9b875f 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2870,6 +2870,40 @@ int qrand() */ /*! + \macro Q_LIKELY(expr) + \relates <QtGlobal> + \since 4.8 + + \brief Hints the compiler that the enclosed condition is likely to evaluate + to \c true. + + Use of this macro can help the compiler to optimize the code. + + Example: + + \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qlikely + + \sa Q_UNLIKELY() +*/ + +/*! + \macro Q_UNLIKELY(expr) + \relates <QtGlobal> + \since 4.8 + + \brief Hints the compiler that the enclosed condition is likely to evaluate + to \c false. + + Use of this macro can help the compiler to optimize the code. + + Example: + + \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qunlikely + + \sa Q_LIKELY() +*/ + +/*! \macro QT_POINTER_SIZE \relates <QtGlobal> |