On Sun, 5 Mar 2006, L505 wrote:
> > > > I guess it's not so hugely useful or else someone would have
> > > > contributed it already.
> > >
> > > Mmm... if that was the case I wouldn't be programming because everyone has
> > > already implemented what I'm trying to program :-)
> > >
> > > Seriously though - it would mean less calls to SetLength when doing big
> > > operations on strings. Ansistrings work fine when you are doing small
> > > random
> > > concatenations but when you do tons at once they are much slower and you
> must
> > > resort to the following:
> > >
> > > setlength(string, NewMaxValue);
> > > string[i]:= 'string I want to concatenate';
> > >
> > > instead of
> > >
> > > string:= string + 'string I want to concatenate';
> >
> > If it helps, we could add a function to TStrings:
> >
> > Function TStrings.Concatenate : String;
> >
> > begin
> > end;
> >
> > Which would optimize the whole matter into a single 'getmem' call ?
> > if there is interest, I can add it. It's 30 minutes of work.
> >
> > Michael.
> >
>
> But I mean if you are doing things at different times in the program:
>
> for i := 1 to 1000
> DoSomestuff
> s:= string + string;
> DoOtherStuff
> s:= string + string;
>
> in other words.. not one big concatenation at once such as:
>
> string.concatenate(string1, string2, string3, string4);
>
> The only way I saw it possible in my mind was through a special string buffer
> type (or hey, even a stringbuffer class if not a true system type).
>
> With TStrings.concatenate did you mean an all at once concatenation?
All strings in the list are concatenated in one step, regardless of
when they were added to the list:
Sl:=TStringList.Create;
for i := 1 to 10000000 do
begin
DoSomestuff;
SL.Add(SomeString);
DoOtherStuff;
SL.Add(SomeOtherString);
end;
Result:=SL.Concatenate; // This can be optimized to 1 getmem call.
Michael.
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives