Can nice D code get a bit slow?

user1234 user1234 at 12.de
Thu Mar 9 11:39:04 UTC 2023


On Wednesday, 8 March 2023 at 12:46:53 UTC, Hipreme wrote:
> On Wednesday, 8 March 2023 at 10:49:32 UTC, Markus wrote:
>> Hi, sorry for the broad and vague question. I have read in 
>> some reddit post about benchmarks, that some code didn't use 
>> the final keyword on methods in a sense that final would make 
>> it faster, I believe.
>>
>> [...]
>
> Don't bother with it. This kind of optimization is done when 
> compiling with -O,

No they are not, simple example : https://godbolt.org/z/xfPqnWrrv
Obviously in a library `test` might be called with a derived so 
`v1()` target address must be read in the vtbl of the argument.

> and I really doubt about your bottleneck being that you're 
> calling a virtual call.

That is more true. vcalls dont add complexity.

> Wait when you actually need to optimize before making your code 
> ugly.




More information about the Digitalmars-d-learn mailing list