Re: [fpc-pascal] interfaces and smartpointers [was Traits Proposal]

2021-02-18 Thread Sven Barth via fpc-pascal
Am 18.02.2021 um 02:25 schrieb Ryan Joseph via fpc-pascal: On Feb 17, 2021, at 4:51 PM, Benito van der Zander via fpc-pascal wrote: I benchmarked it years ago, I do not remember the details. But InitInterfacePointers was bad. Just look at it: That's not great for sure. Fillchar could be

Re: [fpc-pascal] interfaces and smartpointers [was Traits Proposal]

2021-02-17 Thread Ryan Joseph via fpc-pascal
> On Feb 17, 2021, at 4:51 PM, Benito van der Zander via fpc-pascal > wrote: > > I benchmarked it years ago, I do not remember the details. > > But InitInterfacePointers was bad. Just look at it: > That's not great for sure. Fillchar could be a big culprit also actually. I for one would

Re: [fpc-pascal] interfaces and smartpointers [was Traits Proposal]

2021-02-17 Thread Benito van der Zander via fpc-pascal
On 17.02.21 21:43, Ryan Joseph via fpc-pascal wrote: So where is your 10% performance hit coming from then? on init: InitInterfacePointers or TInterfacedObject.AfterConstruction? I benchmarked it years ago, I do not remember the details. But InitInterfacePointers was bad. Just look at it:

Re: [fpc-pascal] interfaces and smartpointers [was Traits Proposal]

2021-02-17 Thread Ryan Joseph via fpc-pascal
> On Feb 17, 2021, at 11:11 AM, Benito van der Zander via fpc-pascal > wrote: > > just open the disassembler window in Lazarus and single step through all the > instructions. Then you see everything > > create alone calls a bunch of methods: > > TInterfacedObject.NewInstance >

Re: [fpc-pascal] interfaces and smartpointers [was Traits Proposal]

2021-02-17 Thread Benito van der Zander via fpc-pascal
Hi, 1) Implicit cast to ITest which does a runtime lookup (but there's interface name so no string comparison like Supports?) just open the disassembler window in Lazarus and single step through all the instructions. Then you see everything create alone calls a bunch of methods:

Re: [fpc-pascal] interfaces and smartpointers [was Traits Proposal]

2021-02-17 Thread Ryan Joseph via fpc-pascal
> On Feb 17, 2021, at 8:27 AM, Benito van der Zander via fpc-pascal > wrote: > > var c: ITest; > begin > c := TTest.Create(123); > c.println; So this is where you're getting your performance penalties? Correct me if I'm wrong but two things happen here: 1) Implicit cast to ITest which

Re: [fpc-pascal] interfaces and smartpointers [was Traits Proposal]

2021-02-17 Thread Benito van der Zander via fpc-pascal
Hi, (1) A record is not a pointer. So that would require some implicit referencing in the property (2) If it was managed, it would be an allocation, so I don't understand this. I am talking about replacing interfaces with an record. For example this