Ryan Joseph <r...@thealchemistguild.com> schrieb am Do., 28. März 2019, 03:01:
> Here’s the basic structure: > > [header][padding][offset][head] > > [head] being the start of the elements (the pointer to the first element > of the array) and aligned to the requested amount. Keep in mind the head is > the pointer which is passed around so we need to subtract back from that in > order to access the header, which contains the array high value and the > refcount. > The order should be [padding] [header] [data] with the offset being part of the header. This way you reduce the changes needed to only those that allocate/free an array. > Look at the dynarr.inc in the /rtl directory to see what I’m talking > about. Pretty hard to explain without seeing how Sven did things. :) > Most of that isn't my code. I only added Insert, Delete and Concat. > > > > The comment: > > As for extending the array header, maybe introduce a new data type > "aligned array". > > So normal arrays do not have that field in there header. > > The plan was to make a “SetLengthAligned” or add an extra parameter to > “SetLength”, i.e, SetLength(arr,100,true). I have no preference, what ever > the compiler team wants. > Extending SetLength is not a good idea as that can take multiple lengths for multi dimensional arrays. Also I don't think that a simple "do alignment or not" will be sufficient. What kind of alignment do you pick? What if the user needs more alignment? So it would probably be best to add a new SetLengthAligned of which the second argument is the alignment followed by the lengths. In dynarr.inc you then add a new setlength variant that takes an additional alignment parameter while the old one without alignment calls the new one with alignment 1. Note: the compiler can call the new one for both variants, but the old one is required for bootstrapping, so you could surround that with {$if not defined(ver3_0) and not defined(ver3_2)}. Regards, Sven >
_______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel