[fpc-devel] Feature request/discussion - SetLengthNoInit

Ryan Joseph genericptr at gmail.com
Wed Sep 16 04:59:17 CEST 2020



> On Sep 15, 2020, at 10:34 PM, J. Gareth Moreton via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
> 
> I'm willing to settle with SetLength(array, len, ... len, NoInit: Boolean = False), but of course it depends on the overall support for it, which isn't looking too promising currently!
> 
> 

I'd rather put the time into making custom list classes perform as well as dynamic arrays. I liked the idea that FPC has it's own native "array of" syntax but it's tied to the language and not flexible enough as we learn from time to time.

Two biggest things I can think of right away:

1) We have management operators now for ref counting but the code is probably not as good as with dynamic arrays (the operator calls are not inlined I know). Also I was never able to get my patch for a Move operator added and I regard this as pretty important to avoid unnecessary copies.

2) I think for the [] operator to work with arrays of records you need to return pointers and enable the "autoderef" modeswitch to avoid the deref syntax (which is how dynamic arrays always work). Are there performance implications of this or do we get the same code as dynamic arrays?


Regards,
	Ryan Joseph



More information about the fpc-devel mailing list