Original Post
I was just wondering, in my app, there's a kind of a gateway function pseudocode: This function is called a lot, and for each instance of SomeClass, a and b never change. The question is, is it worth using a function pointer to cache the decision? In most cases, a and b will evaluate false, so how does a function-pointer call compare to two ifs in terms of performance? The difference will probably be negligable, but I was curious anyway.
bool SomeClass::DoSomething {
if (a)
return DoThingBecauseOfA();
if (b)
return DoThingBecauseOfB();
return DoNormalThing();
}