Skip to Main Content
Delphi High Performance
book

Delphi High Performance

by Primož Gabrijelčič
February 2018
Intermediate to advanced content levelIntermediate to advanced
336 pages
7h 52m
English
Packt Publishing
Content preview from Delphi High Performance

Bulk updates

Another aspect of the same problem of overabundance of messages occurs when you want to add or modify multiple lines in a TListBox or TMemo. The demonstration program, BeginUpdate, demonstrates the problem and shows possible solutions.

Let's say we have a listbox and we want to populate it with lots of lines. The demo program displays 10,000 lines, which is enough to show the problem.

A naive program would solve the problem in two lines:

for i := 1 to CNumLines do  ListBox1.Items.Add('Line ' + IntToStr(i));

This, of course, works. It is also unexpectedly slow. 10,000 lines is really not much for modern computers so we would expect this code to execute very quickly. In reality, it takes 1.4 seconds on my test machine!

We could ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Delphi Cookbook

Delphi Cookbook

Daniele Teti

Publisher Resources

ISBN: 9781788625456Supplemental Content