HappyCoder
17th March 2016, 10:23
Hello,
i have some questions to Q_LIKELY and Q_UNLIKEYLY.
In Qt Docs they wrote it will help the compiler to optimize the code.
Questions:
1.) Does that really give an advantage in speed of my code? I found here in forum
that also the CPU must support it and the benefit of it is not so much.
2.) What if i have two expr. to evaluate
if( expr1 || expr2 )
// Which one is prefered
if( Q_LIKELY(exp1) || Q_LIKELY(expr2) ) // two Q_LIKELY
or
if( Q_LIKELY(exp1 || expr2) ) // in one Q_LIKELY
Thx
i have some questions to Q_LIKELY and Q_UNLIKEYLY.
In Qt Docs they wrote it will help the compiler to optimize the code.
Questions:
1.) Does that really give an advantage in speed of my code? I found here in forum
that also the CPU must support it and the benefit of it is not so much.
2.) What if i have two expr. to evaluate
if( expr1 || expr2 )
// Which one is prefered
if( Q_LIKELY(exp1) || Q_LIKELY(expr2) ) // two Q_LIKELY
or
if( Q_LIKELY(exp1 || expr2) ) // in one Q_LIKELY
Thx