I.T. Discussion Community!
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

October Edition
Subscribe now! It's Free!
Enter your email:

   ► KBProgrammingDelphi for W...Using Data   Print This     
Next Random Article Next Random Tidbit || Change Topic Random From All

Random Tidbit

Part of the mo. lesson in the Oct 15 Issue of Prestwood eMag
Delphi Tip:
 A flashcard from our Delphi Flashcards Library
 A tip from our Delphi Tips Page
TStringList - Maximizing Performance
Before adding many new entries to a TStringList, set its Sorted property to false. Add all your entries. Finally, set the Sorted property back to True (if desired). Sorting is expensive, in terms of macnine cycles. By leaving the Sorted property set to True, you force the TStingList to re-sort itself after each entry. This can significantly slow things down. This applies to TStrings, as well, and all components that have a TStrings property, like TListBox, etc.


Comments

1 Comments.
Share a thought or comment...
Comment 1 of 1

The "correct" way is to use BeginUpdate / EndUpdate regardless of the Sorted flag, even when adding multiple lines to a memo, eg.

oStrings.BeginUpdate;
try
  for nLoop:=0 to 10000 do
    oStrings.Add(IntToStr(nLoop));
finally
  oStrings.EndUpdate;
end;
---
AzzaAzza69
Posted 42 months ago
 
Write a Comment...
...
Sign in...

If you are a member, Sign In. Or, you can Create a Free account now.


Anonymous Post (text-only, no HTML):

Enter your name and security key.

Your Name:
Security key = P1223A1
Enter key:
Tip Contributed By Wes Peterson:

Wes Peterson is a Senior Programmer Analyst with Prestwood IT Solutions where he develops custom Windows software and custom websites using .Net and Delphi. When Wes is not coding for clients, he participates in this online community. Prior to his 10-year love-affair with Delphi, he worked with several other tools and databases. Currently he specializes in VS.Net using C# and VB.Net. To Wes, the .NET revolution is as exciting as the birth of Delphi.

Visit Profile

 KB Article #101180 Counter
19708
Since 6/11/2008

Follow PrestwoodBoards on: 


©1995-2019 PrestwoodBoards  [Security & Privacy]
Professional IT Services: Coding | Websites | Computer Tech