[Lazarus] Memo.Lines.BeginUpdate
zeljko at holobit.net
zeljko at holobit.net
Fri Mar 8 17:04:16 CET 2013
Quoting Juha Manninen <juha.manninen62 at gmail.com>:
> Hi
>
> Shouldn't the BeginUpdate and EndUpdate in TMemo.Lines prevent the GUI
> from updating, thus allowing quickly adding many lines?
>
> I made a test app which generates a big amount of random data and has
> 2 methods to add it to a Memo.
> 1. uses a temporary StringList and finally calls Assign.
> 2. adds the strings directly to Memo.Lines between BeginUpdate and EndUpdate.
>
> Method number 1. is about 40 times faster!
> I expected method number 2. to be the fastest.
>
> The strange thing is that Assign() also uses BeginUpdate and
> EndUpdate, and then calls AddStrings() which has its own BeginUpdate
> and EndUpdate.
> IMO it should behave identically with Memo.Lines.Add inside
> BeginUpdate / EndUpdate.
That highly depends on widgetset. I guess that you're talking about qt
widgetset.
Qt is pretty slow since we do our management of cursor (caret) moving
inside QTextEdit , but if you do bulk load of gazillion of lines then
such code helps:
Memo.beginUpdate;
Memo.WordWrap := False;
for i := 0 to SomeNumOfLines do
Memo.Add(blabla);
Memo.WordWrap := True;
Memo.EndUpdate;
Of course this helps if you really set WordWrap := True; and you use qt ws.
Gtk2 is much faster in this case.
z.
More information about the Lazarus
mailing list