[fpc-pascal] How to inline CompareFunc to Sort method in generic abstract class

Vojtěch Čihák vojtech.cihak at atlas.cz
Mon Nov 14 19:26:17 CET 2022

I wrote a generic abstract class - a list based on dynamic array (i.e. array of T;) and this class can be specialized elsewhere with any type (records or classes).
Part of the class is sorting. There are more ways how to deliver *compare function* to sorting method. I can pass it as a parameter or I can define it as: function Compare(A, B: T): Integer; virtual; abstract;. But this way the function cannot be inlined.
Question: Is there a way how to *inline* compare function to sorting method in this general purpose generic abstract class?
PS: The gain is 6-7%.  

More information about the fpc-pascal mailing list