[Lazarus] Memo.Lines.BeginUpdate

Hans-Peter Diettrich DrDiettrich1 at aol.com
Fri Mar 8 18:22:17 CET 2013


Juha Manninen schrieb:
> 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!

Because here (1) the number of entries to add is known in advance, 
memory can be pre-allocated (Capacity). Not so when individual strings 
are added (2).

The behavior also depends on the widget, whether it stores one text 
(string) or multiple lines. A Windows Memo stores text, so that the 
fastest solution could be
   Memo.Text := StringList.Text;

DoDi





More information about the Lazarus mailing list