[fpc-pascal] Optimize code for speed

L505 fpc505 at z505.com
Fri Jun 10 10:18:48 CEST 2005


What is more optimized code? The problem is.. number 1 is easier to comment the
source code.
Number 2 doesn't waste an extra variable (would it be a pointer? or a copy of
the var? if a pointer, any performance loss..or a very small one?)


1.  begin
       MyString:= Do.Something(somestring);
       StrList3.add(MyString);
     end

2.   begin
       StrList3.add(Do.Something(somestring));
     end

Other optimization questions:

 If you KNOW the string is going to be short, is shortstring and better, or is
 ansistring better?

 If you KNOW the integer is going to be short, is it better to specify a
 ShortInt?
 
 Is the default compiler setting regular strings, or ansistrings?
 
 Is a boolean faster than an integer who you just set as 0 and 1?

Let's pretend that I don't care about compatibility with older computers or
compilers, I just care about optimization in general.






More information about the fpc-pascal mailing list