The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Joined: Aug 09, 2002
Hi, Thanks for the response. I was with the impression that declaring variables outsite a loop is always better since it saves the memory usage ... guess I am actually wrong all this while ...
In general, write the code that makes the makes the most sense when reading/writing it. I say this for 3 reasons:
1. with all the "smart" compiler and JIT run-time optimizations that happen after you write your code, it will probably execute the same code regardless of how it is typed in. 2. If you feel that the complete application you write does not meet speed specifications, then try to optimize the code for speed with the help of a profiling tool. You'll probably find other places where the code is causing the slow down, other than creation of a primitive in a loop. 3. highly optimized code is not always intuitively obvious, readable or maintainable. So, as Ilja always says, The first rule of code optimization is DON'T! Jamie
Joined: Jul 11, 2001
Originally posted by Jamie Robertson: So, as Ilja always says, The first rule of code optimization is DON'T!