I have a code like this
typedef void(_stdcall * MyProcessor)(int, int);
void FunctionProcess (MyProcessor process){
MyProcessor myCallback;
myCallback = (process != NULL)? process:"<functionThatDoesNothing>";
...
}
If there won’t be any callback function in the argument, I’d like to assign some function to myCallback, which would do nothing (or little something), because afterwards, I’m calling this function in loop (and I’d like to avoid ‘if’ in the loop because of the pipeline flush). I’ve tried a no-op lambda with no success (incompatible).
Are there any functions like this? Are there any other possibilities? Thank you.
Your logic is insane! If the
ifis correctly-predicted it will be nearly free. If the indirect jump is incorrectly predicted, it will be horrible. Anifis much easier to predict than an indirect jump (only two possibilities, speculative execution is possible, there are more prediction slots on most CPUs). So there are pretty much no conceivable circumstances where this makes sense.