Initialize arrays from strings with a pc_mov operation.

This is smaller and more efficient than the previous code that called memcpy(). It also avoids a theoretical issue if the user's code included an incompatible definition of memcpy.
This commit is contained in:
Stephen Heumann 2022-12-05 18:00:56 -06:00
parent 0c4660d5fc
commit a7d9d3039b
1 changed files with 3 additions and 8 deletions

View File

@ -4621,15 +4621,10 @@ var
else
size := size-1;
if size <> 0 then begin
GenLdcLong(size);
Gen0t(pc_stk, cgULong);
GenS(pc_lca, iPtr^.iTree^.token.sval);
Gen0t(pc_stk, cgULong);
Gen0t(pc_bno, cgULong);
LoadAddress;
Gen0t(pc_stk, cgULong);
Gen0t(pc_bno, cgULong);
Gen1tName(pc_cup, 0, cgVoid, @'memcpy');
GenS(pc_lca, iPtr^.iTree^.token.sval);
Gen2(pc_mov, 0, size);
Gen0t(pc_pop, cgULong);
if isCompoundLiteral then
AddOperation;
end; {if}