Faster way of making long string?
- From: "Ian Hinson" <pparagon@xxxxxxxxxxxxxx>
- Date: Sun, 24 Apr 2005 10:29:49 GMT
I want to make a string of numbers from an integer list.
The code I'm using is pretty simple solution.
var
i: integer;
lstNumbers: TIntegerList;
strOut: string;
begin
strOut := '';
if lstNumbers.Count > 0 then
begin
strOut := IntToStr(lstNumbers[0]);
for i := 1 to lstNumbers.Count - 1 do
strOut := strOut + ', ' + IntToStr(lstNumbers[i]);
end;
end;
But I'm wondering whether this is an inefficient use of strOut.
It seems to me the program has to keep creating new instances of strOut,
then copy contents of previous instance into it (plus the new number of
course).
Would using "SetLength" to increase the size of the string as required make
a more efficient solution?
If so, could someone please give me an example how this could be done?
Thanks,
Ian.
.
- Follow-Ups:
- Re: Faster way of making long string?
- From: Bruce Roberts
- Re: Faster way of making long string?
- From: Ekkehard Domning
- Re: Faster way of making long string?
- From: Chris Willig
- Re: Faster way of making long string?
- From: Ekkehard Domning
- Re: Faster way of making long string?
- Prev by Date: Re: Delphi Personal Edition (ver 6/7/8)
- Next by Date: Re: Faster way of making long string?
- Previous by thread: Auto Fill Web Forms
- Next by thread: Re: Faster way of making long string?
- Index(es):
Relevant Pages
|