Generics.Collections and Generics.Defaults should not use constref for parameters passed to generic functions
Summary
This is a clear misuse of the constref specifier, since it forces even primitive types to be passed by pointer, which hurts performance. See, for example, TOnComparison<T> / TComparisonFunc<T> and TOnHasher<T> / THasherFunc<T>.
Also note that Delphi also employs const there rather than its own const [ref].
Possible fixes
Just use const everywhere and let the compiler decide. And remember what constref was actually introduced for.
https://wiki.freepascal.org/index.php?title=FPC_New_Features_2.6.0&oldid=156512#Constref_parameter_modifier
System Information
- Compiler version: 3.2.2
P.S.
Maybe we should somehow notify Maciej Izak about this, as it's his library originally (https://github.com/maciej-izak/generics.collections). Unfortunately, I don't see him here on GitLab. IIRC, he was known as hnb back in the Mantis days.