Re: New switch/case idea

new topic     » goto parent     » topic index » view thread      » older message » newer message
kinz said...
jimcbrown said...

Sorry, doesn't count. Your test program has a for loop for the operation[i] = routine_id(opName[i]), but then it stupidly uses the exact same for loop with the switch inside.

Yes, but that one is switching procedure from compile.e, it is not my procedure.

Ok, I didn't notice. It was from an old version of compile.e (as it had the wrong syntax), but that was easy enough to deal with.

I also had to add a couple of routines to handle some missing routines, again no big deal.

Functionality-wise, you are right. This is the InitBackend() from compile.e (oddly, the InitBackend() from execute.e matches your other routine).

kinz said...

Both procedures give strongly equal output.
But my procedure is 50% faster, no?

However, if we change init_opcodes() to use switch on integers instead of on strings, we go from 14.4 to 7.85

So much for the speed advantage.

In any case, InitBackend() is not a speed critical routine, so making the code easy to read and change and debug is more important. The switch statement method is better for this purpose than the parallel arrays version, for the reason I already stated.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu