PRF001
String concatenation in loop
Object Pascal — Delphi & Free Pascal
Warning
Performance
Repeated string concatenation in loops causes O(n^2) memory allocations
repeated string concatenation in loops causes O(n^2) memory allocations.
Why this severity
repeated string concatenation in loops causes O(n^2) memory allocations.
Known false positives
loops with very small iteration counts where performance is not a concern.
Remediation example
var
SL: TStringList;
begin
SL := TStringList.Create;
try
for I := 0 to 100 do
SL.Add(IntToStr(I));
Result := SL.Text;
finally
SL.Free;
end;
end;Related Performance rules