Re: Faster way of making long string?



Sorry, I spoke too soon.
My testing showed that using the TStringList this is *much* faster than my
loop.

"Ekkehard Domning" <edo@xxxxxxxx> wrote in message
news:d4fuke$7me$02$1@xxxxxxxxxxxxxxxxxxxx
> Hello Ian,
>
> Ian Hinson wrote:
> > I want to make a string of numbers from an integer list.
>
> how do You like this?
>
> var
> i: integer;
> lstNumbers: TIntegerList;
> strOut: string;
> sl : TStringList;
> begin
> strOut := '';
> sl := TStringList.Create;
> try
> for i := 0 to lstNumbers.Count-1 do
> sl.Add(IntToStr(lstNumbers[i]);
> strOut := sl.CommaText;
> finally
> sl.Free;
> end;
> end;
>
> All NumberStrings are placed in List, strOut is composed from the list
> strings, list is freed after usage. Should be faster.
> SetLength would be nice, but than You have to call IntToStr twice for each
> entry, first to get the length, second to get the string.
>
>> Thanks,
>> Ian.
>
> Best regards
> Ekkehard Domning


.


Quantcast