optimize TStringHelper.Join mem allocs
rtl/objpas/sysutils/syshelp.inc
class function TStringHelper.Join(const Separator: string;
const Values: array of string; StartIndex: SizeInt; ACount: SizeInt): string;
Var
I,L,VLen : SizeInt;
begin
VLen:=High(Values);
If (ACount<0) or ((StartIndex>0) and (StartIndex>VLen)) then
raise ERangeError.Create(SRangeError);
If (ACount=0) or (VLen<0) then
Result:=''
else
begin
L:=StartIndex+ACount-1;
if L>Vlen then
L:=VLen;
Result:=Values[StartIndex];
For I:=StartIndex+1 to L do
Result:=Result+Separator+Values[I];
end;
end;
Can we optimize/ ie rewrite string reallocs? Alloc the string once, then write to its parts, like TStringList.Text getter.
Edited by Alexey Torgashin