3 ms·
Of all the other replies, it's interesting that no one has mentioned the simplest and probably most efficient implementation, the one based on gotos: state
by userbinator 4y ago
Of all the other replies, it's interesting that no one has mentioned the simplest and probably most efficient implementation, the one based on gotos:
state_x:
... do some stuff ...
if(some_condition)
goto state_y;
else if(some_other_condition)
goto state_z;
else
goto state_n;
...
state_y:
...