[Lazarus] What is the most efficient construction?

Arí Ricardo Ody nightrider43 at gmail.com
Sun Jul 28 13:44:07 CEST 2024


Hi guys

A question that I have had for a long time:

Suppose I have the variable

list:TStringList

and I want to iterate through the items through the items in list.

Between the construction:

For i := 0 to list.Count - 1 do
begin;
  commands
end;

And the construction

j := list.Count - 1;
For i := 0 to j do
begin;
   commands
end;

Which would be the most efficient?

I ask because I have the impression that in the first construction it will
be necessary to generate code to determine the value list.Count - 1 at each
iteration of the For loop.

Greetings from São Paulo - Brazil

Arí Ricardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20240728/5d6aa406/attachment.htm>


More information about the lazarus mailing list