Delphi Runtime Library is one of the foundations of the product, as the UI libraries such as VCL and FireMonkey and also database access libraries and many third party components reply on the core RTL. That is why changes to the RTL are particularly relevant, as they tend to affect all developers. Here are some key changes that are now available.
Table of Contents
Bit Counting Standard Functions
We have introduced new standard functions for common low-level bit processing operations, listed below.
- Count Leading Zeros: Counts the number of leading zero bits preceding the most significant one bit of the parameter X. If X is zero, it returns the bit width. i.e. 32 for CountLeadingZeros32 and 64 for CountLeadingZeros64
- Count Trailing Zeros: Counts the number of trailing zero bits following the least significant one bit of the parameter X. If X is zero, it returns the bit width. i.e. 32 for CountTrailingZeros32 and 64 for CountTrailingZeros64.
- Count Population: Counts the number of 1 of the parameter X. Return value will be in the range from 0 to the bit width. i.e. 32 for CountPopulation32 and 64 for CountPopulation64
Additional Features for Classic Classes
- The TCustomIniFile class has new methods WriteInt64 and ReadInt64
- The TGUID type has a new IsEmpty method
- The Items property of the TJSONArray class is now a default array property, allowing you to write myJArray rather than myJArray.Items
Better Stream Buffering
The CopyFrom function of the base TStream class used to have a fixed constant buffer for copying data (set to 60K). This can be very inefficient for copying large streams. The new default is 1MB, but the method has an additional parameter you can use to provide a specific buffer size depending on the copy operation you are doing (source and target streams). The new signature of the method is
// class TStream
function CopyFrom(const Source: TStream; Count: Int64 = 0;
BufferSize: Integer = $100000): Int64;
- JSON reading optimization: TJSONReader is now 50% faster
- Optimized assigning a sorted StringList to another StringList
- RTTI performance improvements include:
- TRttiMethod.Invoke is ~ 4 times faster
- TVirtualInterface invocation is ~ 1.7 times faster
- TRttiType.GetXxxx(AName) methods are ~ 10 times faster
- For TValue several operations are faster
- The QuickSort operation in System.Classes is now more efficient
We updated the signature of the FreeAndNil procedure, to avoid its use with interface references and other unsupported data types. It is now declared to require a reference to a TObject:
procedure FreeAndNil(const [ref] Obj: TObject); inline;
This means that incorrect usage of FreeAndNil will now cause a compiler error. In the past, incorrect usage would not be caught, leading to difficult bugs. Note that although the parameter is declared as const, the by-reference variable is indeed modified.
Additional Assorted Features
- We have removed some dependencies blocking certain console apps to run on Windows Server Core
- The TStringHelper.GetHashCode method has been updated not to uppercase the string before hashing it, so its result matches other internal operations like the TStringComparer class.
That’s just a partial list. We have also done quite some work on the Parallel Programming Library, AppTethering, the REST and HTTP client libraries and more of the other Delphi RTL subsystems. Hope these improvements, even if relatively minor, will be appreciated for their positive impact in every day Delphi developers work.
Learn more about RAD Studio 10.4 and download your 30 day free trial on our website
Design. Code. Compile. Deploy.
Start Free Trial Upgrade Today
Free Delphi Community Edition Free C++Builder Community Edition
I have Delphi 10.4 Update 1 but don’t see CountxxxxxZeros or CountPopulation yet?
What do you mean by “I don’t see”? These are compiler intrinsic, so they are not declared as regular functions but you can invoke them, like in:
X := 100;
ShowMessage (CountLeadingZeros32 (X).ToString);