Mattias Gaertner wrote:
> Al Boldi <[EMAIL PROTECTED]> wrote:
> > Mattias Gaertner wrote:
> > > Al Boldi <[EMAIL PROTECTED]> wrote:
> > > > > > Preallocating the tree in TTreeView could improve its speed a
> > > > > > lot.
> > > > >
> > > > > I doubt that. It already works with exponential growth.
> > > >
> > > > Preallocate in 16sec ============
> > > > TreeView1.BeginUpdate;
> > > > TreeView1.Items.Clear;
> > > > for i:=1 to 100000 do
> > > > TreeView1.Items.Add(nil,'');
> > > > TreeView1.EndUpdate;
> > >
> > > I improved it. Please try.
> >
> > Do you have a patch against 0.9.15?
>
> I can create one, but I'm not sure, if the rest of 0.9.15 will work
> with it.
> Attached.
Thanks!
It didn't apply, but with this change
/////////////
else if Index>Count-5 then begin
// optimization for the last nodes
Result:=GetLastSubNode;
i:=Count-1;
while (Index<i) do
Result:=Result.GetPrev;
end
/////////////
on this
> No preallocation > 2min ^C ======
> TreeView1.BeginUpdate;
> TreeView1.Items.Clear;
> for i:=1 to 100000 do begin
> TreeView1.Items.Add(nil,'tst'+inttostr(i));
> for j:=1 to 10 do
> TreeView1.Items[i-1].Text:=IntToStr(i)+','+IntToStr(j);
> end;
> TreeView1.EndUpdate;
> =================================
speeds thru in 19sec.
TStringGrid is still 4 times faster.
What change is required for preallocation?
Thanks!
--
Al
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives