> I think first code is faster than second, because in first code > SubCalculate function is in calling function body?
Actually some times local scope functions are slower because the variables need to be carried around since you are doing somewhat of a lexical closure. The local scope function can have hidden variables being passed in since it needs to know about the parent function variables. So don't assume local scope is faster always. Assume it is slower, but do testing to verify. It could even be faster in some cases.. for example if you really do need to access all the variables in one place. > > P.S. Where i can read tips about writing fast FP code? I hear the Intel C compilers and Fortran compilers and Ada compilers are better optimized for certain things since FPC/delphi are generally desinged for GUI programming. ;-) I've never had speed problems when I closely check my SetLength cals, Length() calls on pchars. Too many class instantiations in a loop can slow down a bit, or too many except calls in a loop. Basically, optimizing Loops is the key always when it comes to performance. -- L505 http://z505.com _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal