I was wondering... if I had many different functions that I wanted to call based on what the value of a variable would be, and the limits of that value where integral [0, N) , would the second method be much faster than the first?:
1st:Code:void proc1(); void proc2(); ... void procN();
2nd:Code:switch (value) { case 0: proc1(); break; case 1: proc2(); break; ... case N-1: procN(); break; }
In the case of indexing though, what "guessing" rules would apply, if any?Code:typedef void (*procedure)(); procedure procArray[N] = { proc1, proc2, ... , procN }; ... procArray[value]();



6Likes
LinkBack URL
About LinkBacks




), and I thought I could use the opcodes as indices!
It'd be nice if I managed to get it to run at approx 300 IPS( speaking about the Kenbak-1 ) with less than 5% of my CPU( Core2 Duo 2.4GHz )
.