Skip to content

Improve dynarray_delete and concat(_multi), add string-like optimizations.

Rika requested to merge runewalsh/source:daconcat into main
  • 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, check if source+count-1>pdynarray(p-sizeof(tdynarray))^.high then overflows on delete(arr, 2, high(sizeint)) (possibly resulting in an invalid array with high < -1) which can easily be avoided.

  • In fpc_dynarray_concat_multi, first if length(sarr)=0 then is superfluous because (is dead and) will lead to totallen=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).

Merge request reports