<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body smarttemplateinserted="true">
    <div id="smartTemplate4-template"><br>
    </div>
    <div class="moz-cite-prefix">On 17.02.21 21:43, Ryan Joseph via
      fpc-pascal wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:71BB48E1-867F-4033-9B27-3CECCF3B7A63@gmail.com">
      <pre class="moz-quote-pre" wrap="">So where is your 10% performance hit coming from then? 

on init:

InitInterfacePointers or TInterfacedObject.AfterConstruction? 
</pre>
    </blockquote>
    <p><br>
    </p>
    <p>I benchmarked it years ago, I do not remember the details.</p>
    <p>But InitInterfacePointers was bad. Just look at it:<br>
    </p>
    <p>      procedure InitInterfacePointers(objclass: tclass;instance :
      pointer);<br>
      <br>
              var<br>
                ovmt: PVmt;<br>
                i: longint;<br>
                intftable: pinterfacetable;<br>
                Res: pinterfaceentry;<br>
              begin<br>
                ovmt := PVmt(objclass);<br>
                while assigned(ovmt) and {$ifdef
      VER3_0}(ovmt^.vIntfTable <>
      @emptyintf){$else}assigned(ovmt^.vIntfTable){$endif} do<br>
                  begin<br>
                    intftable:=ovmt^.vIntfTable;<br>
                    {$ifdef VER3_0}<br>
                    if assigned(intftable) then<br>
                    {$endif VER3_0}<br>
                    begin<br>
                      i:=intftable^.EntryCount;<br>
                      <span class="moz-txt-link-abbreviated"><a class="moz-txt-link-abbreviated" href="mailto:Res:=@intftable^.Entries">Res:=@intftable^.Entries</a></span>[0];<br>
                      while i>0 do begin<br>
                        if Res^.IType = etStandard then<br>
                          ppointer(@(pbyte(instance)[Res^.IOffset]))^:=<br>
                            pointer(Res^.VTable);<br>
                        inc(Res);<br>
                        dec(i);<br>
                      end;<br>
                    end;<br>
                    ovmt:=ovmt^.vParent;<br>
                  end;<br>
              end;<br>
      <br>
    </p>
    <p><br>
    </p>
    <p>But reusing objects avoids calling all the functions from create.
      (but reusing is also expensive, besides the memory increase, it
      needs a free list and thread safe handling of the head of the
      list)<br>
    </p>
    <p><br>
    </p>
    <blockquote type="cite"
      cite="mid:71BB48E1-867F-4033-9B27-3CECCF3B7A63@gmail.com">
      <pre class="moz-quote-pre" wrap="">otherwise, during the wrapper function? As Sven pointed out the ref counting happens with records operators also. ARC is general may just be slow if you implement it everywhere.</pre>
    </blockquote>
    <p><br>
    </p>
    <p>The wrapper function was not included in the 10%<br>
    </p>
    <p><br>
    </p>
  </body>
</html>