[fpc-pascal] Array clearing

Jonas Maebe jonas at freepascal.org
Sun Apr 2 11:53:37 CEST 2017


On 02/04/17 11:22, Ryan Joseph wrote:
>> On Apr 1, 2017, at 9:25 PM, Jürgen Hestermann <juergen.hestermann at gmx.de> wrote:
>>
>> If you just need to reuse the same array and only need to zero its elements
>> then of course fillchar would be the fastest approach (it saves the memory
>> reallocation step).
> Why is this “of course”? What’s the implementation of FillChar exactly? For all I know it has to iterate over a range of bytes and this could be slower than allocation of memory. Maybe some of the compiler people know these details.

Allocating new memory via setlength also clears the memory (+ the 
overhead of allocating the memory).


Jonas



More information about the fpc-pascal mailing list