[fpc-devel] Optimizations
Martin Frb
lazarus at mfriebe.de
Fri Jan 24 02:15:59 CET 2014
On 24/01/2014 01:03, Martin Frb wrote:
>
> Until that is done, your best choice, if you need the speed is to do
> this by hand:
>
>
> or better
> if cnt = 0 then exit;
> tmpptrA := @a[0];
> tmpptrB := @b[0];
> for i := 0 to cnt - 1 do
> begin
> tmpVAlue := tmpptrA^ + tmpptrB^;
> tmpptrA^ := tmpVAlue;
> inc(tmpptrA); // assuming a typed pointer
> tmpptrA^ := tmpVAlue;
> inc(tmpptrB); // assuming a typed pointer
> end;
Actually, if the late hour has not clouded my sight, it goes even better.
tmpptrA := @a[0];
tmpptrB := @b[0];
tmpVAlue := tmpptrA^;
for i := 0 to cnt - 1 do
begin
tmpVAlue := tmpVAlue + tmpptrB^;
tmpptrA^ := tmpVAlue;
inc(tmpptrA); // assuming a typed pointer
inc(tmpptrB); // assuming a typed pointer
end;
tmpptrA^ := tmpVAlue;
the last is actually a[cnt], not sure if intended, but it is done so in
the original code too.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20140124/538a37e4/attachment.html>
More information about the fpc-devel
mailing list