I have often wanted to point this out, but didn't really feel the need to, until today, when I was debugging into the RTL.
When you have a string parameter, the compiler makes a call to the RTL routine _UStrAddRef, and _UStrClr.When you have multiple string parameters, the compiler makes a call for each string parameter to _UStrAddRef, and one call to _UStrArrayClr. In addition, the compiler will compile code similar to a try finally sequence as well.
If you do not make any changes to the string parameter, it is better to make that string parameter a const.
So, assuming you have the following code pattern:
procedure AName(param1: string)
changing it to:
procedure AName(const param1: string)
reduces the 2 calls generated by the compiler.
Here's the disassembly for the procedure X(S1, S2: string)
and here's the disassembly for Y(const S1, S2: string):
As you can see, without the const, the generated code is more verbose.
In 2017, with the release of Delphi 10.2 Tokyo, Embarcadero introduced a specialized implementation of the Observer pattern into the System.Classes unit. While it has been in the wild for 9 years, it remains a "hidden" architecture for many, primarily because it serves as the invisible engine behind LiveBindings. Other than live bindings, you can also use the Observer pattern as a way to update component settings to the Windows registry, an .ini file, or persist it elsewhere.
System.Classes