Hi,
i have a program's main loop performing different actions depending on it's "mode" (let's pretend the mode is just an integer from an enum).
These actions are repeated many times, while the mode changes rarely; then, instead of checking the mode variable every single time the loop occurs, i thought why not just put a function pointer there, and change the pointer to a different function when mode changes?
Now my question is, does anyone do that or i'm just being totally crazy?
Hmm... I don't know... I don't like that three separate things have to be set correctly in order to perform a mode change. That looks like a copy-paste error waiting to happen.
Is there any way to put the mode-independent bits in functions, so that you merge those functions into