Re: New switch/case idea
- Posted by kinz Apr 08, 2009
- 1625 views
This was changed
Let's come back? Why not?
By having the routine_id function call with a literal string is faster than using a runtime string expression. The value of the routine_id can be determined at parse-time once with literals, otherwise it has to do a look up every time its executed when using string expressions. Also, with literals, the bind program (and a future optimised translator) can see which routines are referenced and can strip out unreferenced routines. If you have even one routine_id() that uses a runtime string expression, then bind cannot strip out any routines just in case you need it at runtime evaluation of routine_id().
jimcbrown and me are talking about the global procedure init_opcodes() of the compile.e file. This procedure only used in the local function InitBackEnd() of the traninit.e lib. Used once, just one call, as far as I can see. It prepares the sequence with routine numbers (routine_ids). So, the testing of the real speed of different versions of such a procedure seems to be not very difficult. The sequence of routine_ids has the 'operation' name. Once it is filled with routine_ids, the init_opcodes() procedure is done. So, I do not see the runtime string expressions which compete with literal strings at runtime frequently in this case. Just one call to init something.
There are yet another switches in source code, I didn't see them for now.
kinz