[fpc-pascal] Delphi mode syntax error

Jonas Maebe jonas.maebe at elis.ugent.be
Tue Jan 19 15:29:00 CET 2010


On 19 Jan 2010, at 15:14, Marco van de Voort wrote:

> Hmm, under delphi at least, it is cheaper to do
>
> var pstart,pend : PSomeType;
>
> if length(sometypedynarray)>0 then
>  begin
>    pstart:=@sometypedynarray[0];
>    peind :=@sometypedynarray[length(sometypedynarray)-1];
>    while (pstart<=peind) do
>      begin
>        operate_on(pstart);
>        inc(pstart);
>      end;
>  end;
>
> then for i over a dynarray, even if sometype is a simple type.

I can't imagine why that would be any faster than a simple for-loop,  
except for an implementation detail in the code generator or optimiser  
of the tested Delphi version(s) (or in case range checking is enabled  
-- but in that case using pointers to work around range checking would  
be strange). And it most certainly looks a lot worse than

for i:=0 to high(sometypedynarray) do
   operate_on(sometypedynarray[i]);

It would also surprise me if any speed difference that may exist were  
significant.


Jonas



More information about the fpc-pascal mailing list