Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
DelphiNewsRAD Studio

Faster Delphi RTL with Parallel Arrays and Ordered Dictionaries

faster delphi rtl

While the most relevant new features were in other product areas, there are a few enhancements in the Delphi Run Time Library (o RTL) that we thing is worth pointing out.

New TParallelArray Class

There is a new TParallelArray class in the System.Threading unit that enables running operations like &For and Sort in parallel on Array items. On multi core systems, this can speed them up considerably. How can you use it? This is a simple test case, command line project, which creates two identical arrays and sorts them with the regular single-thread Sort and the new parallel version:

If I run it on my main computer, an Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz , I get the following results, a nice 585% improvement! (output trimmed to milliseconds for readability)

New TOrderedDictionary Class

There is also a new TOrderedDictionary class, derived from TDictionary<K,V>, in the System.Generics.Collections unit. An Ordered Dictionary is a dictionary with integrated sorting methods in the dictionary. This makes is simple to have a for in loop navigating the data in a sorted order, and also makes it faster to locate elements. As an example, take a look at the following project which:

  • Creates an ordered dictionary and adds some elements to it
  • Displays the output and the time it takes to find a key 100 million times
  • Sorts by key, displaying the output again and repeating the 100 million find calls (much faster!)
  • Sorts by value and displays again
  • Adds an extra element, to prove elements are not added with the sort order, you need to resort as needed (this is generally faster, when inserting multiple elements)

This is the complete output:

A Few More RTL Enhancements

  • The TRegistry class has been extended with improved rdMultiString support and the new methods ReadNone and WriteNone (which map to the REG_NONE Windows registry data type).
  • We improved RFC822 dates support in the System.DateUtils.
  • We are now shipping map files for Delphi runtime packages distributed with RAD Studio

That’s all for this blog post, hope you’ll be able to start leveraging these and the many other new RTL features added in recent releases in your projects.

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

Marco is one of the RAD Studio Product Managers, focused on Delphi. He's the best selling author of over 20 books on Delphi.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES