Problem Source: http://www.cnblogs.com/del/archive/2008/06/04/1101970.html#1217512
Stringofchar is a function that repeats "character" into "string;
Dupestring is a function that repeats "string" into "New String;
Stringofchar comes from the system unit and can be used directly;
Dupestring comes from the strutils unit, which requires uses strutils;
If it is only repeated "characters", of course, stringofchar should be used, which is an assemblyCodeThe implementation speed will be slightly better.
The following is the test code:
Unit unit1; interfaceuses windows, messages, extensions, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; Procedure formcreate (Sender: tobject); Procedure button1click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} uses strutils; {dupestring from this unit} procedure tform1.formcreate (Sender: tobject); var STR: string; begin STR: = system. stringofchar ('A', 5); showmessage (STR); {AAAAA} STR: = strutils. dupestring ('A', 5); showmessage (STR); {AAAAA} STR: = strutils. dupestring ('abc', 5); showmessage (STR); {abcabcabcabcabc} end; {stringofchar is certainly faster if it is only repeated characters; speed test:} procedure tform1.button1click (Sender: tobject); var T1, T2: Cardinal; I: integer; begin T1: = gettickcount; for I: = 0 to 1000000 do dupestring ('A', 5); T1: = gettickcount-T1; t2: = gettickcount; for I: = 0 to 1000000 do stringofchar ('A', 5); t2: = gettickcount-t2; showmessagefmt ('dupestring: % d; stringofchar: % d', [T1, T2]); end.