Function pointers for opcode execution
Posted: Wed Nov 16, 2011 11:31 pm
I'm not a very experienced programmer, so the following question/suggestion may come as silly.
Looking at the Snes9X source code, I came across an interesting and important line:
It seems function pointers are used for executing opcodes. I am tempted to ask, wouldn't a switch statement be (at least somewhat) faster ? I base this statement on a quote I read some time ago:
Looking at the Snes9X source code, I came across an interesting and important line:
Code: Select all
(*Opcodes[Op].S9xOpcode)();
(source: http://stackoverflow.com/questions/4708 ... erformance)[to optimize a VM] use a large switch-case instead of a table of function pointers (the compiler will optimize to a jump table, and you remove the overhead of actually calling the function)