Exists in Delphi something like the Java or C# StringBuilder? Or Delphi does not need StringBuilder and s := s + \'some string\';
is good expression (mainly in for,
Yes, Delphi offers TStringBuilder (since version 2009):
procedure TestStringBuilder;
var
I: Integer;
StringBuilder: TStringBuilder;
begin
StringBuilder := TStringBuilder.Create;
try
for I := 1 to 10 do
begin
StringBuilder.Append('a string ');
StringBuilder.Append(66); //add an integer
StringBuilder.Append(sLineBreak); //add new line
end;
OutputWriteLine('Final string builder length: ' +
IntToStr(StringBuilder.Length));
finally
StringBuilder.Free;
end;
end;
And yes, you are right. s := s + 'text';
isn't really slower than using TStringBuilder.