Re: Load time trimming
- Posted by Robert Craig <rds at MSN.COM> Jul 22, 1997
- 797 views
Craig Gilbert writes: > 1) Suppose you are writing an app. that involves using pieces of many > different include files, but *only* pieces of those include files. That is, > one function out of this one, another from that one, etc. Euphoria does not do any special optimization here. It will load the unneeded functions and will not try to reclaim their allocated memory later. A perfectionist could try to pick and choose precisely the set of routines that he needs. This would save him a few milliseconds of load time and a few K of memory. > 2) Does anyone know of a way to emulate a case statement in Euphoria other > than an elsif chain? The case statements I'm referring to are like Qbasic's > Select Case, or C's switch(). > Nothing wrong with elsif chains, I'm just curious if it can be done. In the interests of simplicity, a case statement was never added to Euphoria. elsif chains are used instead. In some situations a case statement might be more readable, and possibly more efficient. I have some ideas for optimizing certain elsif-chains to match the efficiency of case statements, but I've never seen a Euphoria program where the linear series of comparisons implied by elsif was slowing the program down very much. (With case statements you can often set up a fast n-way branch, by indexing into a jump table.) If you *are* being slowed down, run "with profile", and reorder your elsifs to put the most common cases first. You can also set up a kind of binary search for the matching case, using nested if statements, rather than just doing a linear series of elsif's. There are hundreds of language features that are completely justifiable when viewed in isolation, but if you implement all of them you create a mess (like C++). Regards, Rob Craig Rapid Deployment Software