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:
[crayon-673ef9f49881b341371262/]
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)
[crayon-673ef9f498828457284780/]
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)
[crayon-673ef9f49882c409078984/]
This is the complete output:
[crayon-673ef9f49882e107060223/]
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.