Hello!
I would like to know to which extend is recommend to use Q_UNLIKELY and Q_LIKELY in one's code, that is, exactly which situations I should consider "likely" or "likely" to happen so it may present an advantage on using such macros?
In the Qt Assistant, the example given is one in which the user selects a file and tries to open it. In such situation is almost impossible for the file mysteriously be deleted between the user selecting the file and the application trying to open it, "a chance in one million". But lets say that I have a situation in which a occurrence of a "negative" event (negative related to the macro being used between those two) is far more likely or even certain to occur in some point. For example, a loop for of 10, 100 or 1000 iterations where the validation conditional (the expression that falls in the middle of the for, or even the expression inside while()) is therefore going to be hit in 1/10, 1/100 or 1/1000 of the times. In such situations is it still valid to use those two macros or maybe they will even slow down the code or something else?
Thanks,
Momergil
Bookmarks