[fpc-pascal] Array clearing

Sven Barth pascaldragon at googlemail.com
Sat Apr 1 12:31:25 CEST 2017


Am 01.04.2017 10:35 schrieb "Ryan Joseph" <ryan at thealchemistguild.com>:
>
>
> > On Apr 1, 2017, at 2:50 PM, Ryan Joseph <ryan at thealchemistguild.com>
wrote:
> >
> > Yeah, I was concerned with just compiler types or weakly retained
classes where I’m just keeping the reference.
>
> Another question. Is it more efficient/faster to reallocate a new array
of the same size or call FillChar on the existing array?

I think that FillChar should be faster as reallocating would need setting
the array to Nil and recreating it (SetLength with the same length won't
touch the existing elements) thus loosing any gain of reallocate and then
there'd still be the internal FillChar of the array.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170401/91b5aba8/attachment.html>


More information about the fpc-pascal mailing list