<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Am 18.11.2022 um 20:44 schrieb Flávio
Etrusco via fpc-pascal:<br>
</div>
<blockquote type="cite"
cite="mid:CAJvBmOaMXLJKB1nsJX6z9=oNTTVG_KzG-MNrcteghKAKLL1q=g@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="auto">
<div><br>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">Em seg., 14 de nov. de
2022 15:26, Vojtěch Čihák via fpc-pascal <<a
href="mailto:fpc-pascal@lists.freepascal.org"
rel="noreferrer" target="_blank"
moz-do-not-send="true" class="moz-txt-link-freetext">fpc-pascal@lists.freepascal.org</a>>
escreveu:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
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).<br>
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.<br>
<br>
Question: Is there a way how to *inline* compare
function to sorting method in this general purpose
generic abstract class?<br>
<br>
Thanks.<br>
<br>
PS: The gain is 6-7%. <br>
</blockquote>
</div>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">Hi,</div>
<div dir="auto"><br>
</div>
<div dir="auto">What do you mean by "be inlined"? The 'inline'
directive instructs the compiler (or is it the linker? 😬)
to try copying the whole function inline, also avoiding the
call (stack) setup; you can't do this for this for a general
purpose method.<br>
</div>
</div>
</div>
</blockquote>
<br>
Inlining is done by the compiler, not the linker. Also inlining does
work for methods (at least in general; there are exceptions to this,
e.g. if the method is virtual or uses "inherited"). What it can't be
done with is method pointers (or function pointers).<br>
<br>
Regards,<br>
Sven<br>
</body>
</html>