I have a code that goes like:
++state;
do_work();
--state;
do_work might modify and use state. I cannot simply replace state with state+1 in do_work.
Would using a temporary variable be faster than decrementing on a mainstream processor such as an Intel or ARM?
int tmp = state++;
do_work();
state = tmp;
Before you say that I am doing premature optimization, I will use the clearer first way over the last way regardless. I am just curious if that is actually slower than the other way.