In another thread, ASerge made a couple of observation. ASerge, I hope you don't mind me quoting you here ?
1. aBox.Items.Count is called three times. Property properties - it is better to write to a local variable.
2. For indexes, I prefer the processor-optimized SizeInt type instead of Integer.
I'd really like to know more about these sort of issues. For example -
* How many times would you need to call a property before its better to cache it locally ? That would, IMHO, depend on the type too, the cost of declaring an integer and copying data to it would be less than, say a string (that is generally a managed ANSIString for most of us).
* A "processor-optimized SizeInt" ? but maybe there would be more to be saved by just using a 32bit var in all cases ? A 32bit operation would be faster than a 64bit one even on a 64bit machine ? And save a touch of memory ? Most of the examples I can think of could, just, get away with a 16bit so 32bit is outrageously 'safe'.
* How much slower is it to ask another unit (or class) the value of one of its variables compared to a local var ?
Although its no longer fashionable to consider how such things might speed an app up fractionally or save a few bytes of memory footprint, I like to but can find little written on the topic specifically about FPC use.
Davo