I think we all connected… “We are Borg. You will be assimilated. Resistance is futile”… weird…

Do you know a rest of it? “But we’re not at home right now, so leave a message after the tone and we’ll assimilate you later… (beep)” 😉 (link)

Ok, lets come back to the strings… 2 weeks ago Chris Bensen (CodeGear’s Sr. R&D engineer) wrote in his blog about STRING type being passed as parameter and what are associated “costs” for your application. Very good thing to read along with discussion. Of course many have known about this at some point while working with Delphi, but value of the post that it brings it all together and shows why it happens.

More to it for know source (Delphi help):

Constant Parameters (Delphi 2006)
A constant (const) parameter is like a local constant or read-only variable. Constant parameters are similar to value parameters, except that you can’t assign a value to a constant parameter within the body of a procedure or function, nor can you pass one as a var parameter to another routine. (But when you pass an object reference as a constant parameter, you can still modify the object’s properties.) Using const allows the compiler to optimize code for structured – and string-type parameters. It also provides a safeguard against unintentionally passing a parameter by reference to another routine.

Reading classics:

PS. I think  if you are on this level of optimization, then there is probably something wrong with the design of your app itself. “What-not-to-do” or “How-to-do-things-in-the-right-way” should be in your style of programming and not a magic wand to squeeze a few milliseconds out of your application…

Enjoy results of your findings.

Categories: Delphi

0 Comments

Leave a Reply