- DelphiTools - https://www.delphitools.info -

String concatenation redux

In addition to several fixes and improved error detection and messages (thanks Alexey Kasantsev), the DWScript SVN version now includes string concatenation improvement for the common “s := s + …” case.

Just for illustration, the execution times for the following test snippet

for i:=1 to 5000000 do
   buf := buf + IntToStr(i);

are right now on my machine:

and when appending constant strings

for i:=1 to 5000000 do
   buf := buf + 'abc';

the timings are:

I didn’t include PascalScript, as its execution times were too long, in both cases.

Oddly enough, it’s now faster to concatenate using the “s:=s+…” or “s+=…” patterns than using TStringBuilder. This is in part thanks to FastMM, in part because of TStringBuilder, and in part because TStringBuilder does not yet benefit from a “fast path” in DWScript.