12
votes
All hail the “const” parameters!
DelphiTools
– Passing parameters as “const” is a classic Delphi optimization trick, but the mechanisms behind that “trick” go beyond cargo-cult recipes, and may actually stumble into the “good practice” territory. Why does it work? The most well known case is “const String“, for which the compiler than takes advantage of the “const” to pass the String reference directly (as a pointer)… and without increasing the reference counter. To illustrate what the reference counting implies, here are two screen-shots from the CPU disassembly view, taken ...
Statistics
|
Visits by Source |
User Actions |



