Improve dynarray_delete and concat(_multi), add string-like optimizations.
-
As in #40417 (closed), prefer variables without addresses.
-
{$ifdef VER3_0}
parts don’t have a chance to get enabled because there is an outer{$ifndef VER3_0}
already. -
In
fpc_dynarray_delete
, checkif source+count-1>pdynarray(p-sizeof(tdynarray))^.high then
overflows ondelete(arr, 2, high(sizeint))
(possibly resulting in an invalid array withhigh < -1
) which can easily be avoided. -
In
fpc_dynarray_concat_multi
, firstif length(sarr)=0 then
is superfluous because (is dead and) will lead tototallen=0
anyway. -
Optimize appending to the array and concatenating with empty arrays. I don’t quite understand what the comments claiming it’s not possible imply; if only that the destination array may occur among the inputs, then I’ve got it covered.
Added a test that presently fails every single thing it checks (and crashes when it starts to check array of string
, or right away if run under -gh: Use heaptrace unit
).