4 ms·
This article seems to make performance assertions that are not supported by what actually happens. E.g. "Passing by value is slower, since a new variable has t
by evmar 3y ago
This article seems to make performance assertions that are not supported by what actually happens.
E.g. "Passing by value is slower, since a new variable has to be created. Passing by reference just passes an address and the code uses that address – no new variable is created." is not right for the example involving an int*, as passing a pointer is clearly as much data to copy as an int (and in the non-pointer case it will all end up in (faster) registers).
Similarly if you paste the "Returning a copy of a structure" example into godbolt you'll see GetDateTime4 writes directly into the caller's pointer. https://godbolt.org/z/Wj4Gn1YaP https://godbolt.org/z/Wj4Gn1YaP