S
Sean Kenwrick
I have a large switch statement (~50 cases ) inside a critical inner loop of
a byte code interpreter I am working on, and I am wondering if I should take
any steps to optimise this loop.
Are switch statements usually compiled as if...else if..else if...else type
statements? Are there other ways that the compiler could implement switch
statements that are more efficient?
With regards to my code, would it be better to put the most common cases
near the top of the switch statement or should I consider making a lookup
table of function pointers instead (but the function call overhead might
kill it) - this is the first time that I wish I could put labels into arrays
and do 'goto label[x]' )
I've tried posting to comp.compilers but nothing has appeared in this group
for iver a week and it seems to be dead ....
Any advice, hints etc would be appreciated...
Sean
a byte code interpreter I am working on, and I am wondering if I should take
any steps to optimise this loop.
Are switch statements usually compiled as if...else if..else if...else type
statements? Are there other ways that the compiler could implement switch
statements that are more efficient?
With regards to my code, would it be better to put the most common cases
near the top of the switch statement or should I consider making a lookup
table of function pointers instead (but the function call overhead might
kill it) - this is the first time that I wish I could put labels into arrays
and do 'goto label[x]' )
I've tried posting to comp.compilers but nothing has appeared in this group
for iver a week and it seems to be dead ....
Any advice, hints etc would be appreciated...
Sean