type
TMyRec = record
O: TObject;
S: String;
end;
TMyRecArray = array of TMyRec;
function BuildRecArray: TMyRecArray;
begin
SetLength(Result, 1);
Result[0].O := nil;
Result[0].S := 'x';
end;
procedure BuildRecArray(var Result: TMyRecArray);
begin
SetLength(Result, 1);
Result[0].O := nil;
Result[0].S := 'x';
end;
var
Result: TMyRecArray;
begin
BuildRecArray(Result); //or Result := BuildRecArray
end.
Looking at the generated assembly revealed that the function version (returns the array in the result) leads to bigger code when compared with the procedure version (pass the array as a var parameter). More: the code difference is due to an implicit exception frame which is known to impact performance.
And what about the caller code? Again the function version generates more code (creates a temporary variable and calls FPC_DYNARRAY_DECR_REF).
In short: yes, it matters.