On Sunday, 4 October 2020 at 15:30:48 UTC, IGotD- wrote:
I don't agree with this, especially if the struct is 432 bytes. It takes time and memory to copy such structure.

If the compiler chooses to inline the function (which happens quite frequently with optimizations turned on), no copy takes place regardless of how you write it if the compiler can see it is unnecessary.

Returning a struct by value rarely means a copy either since the compiler actually passed a pointer to where it wants it up front, so it is constructed in-place.

So like "pass by value" in the language is not necessarily big copies in the generated binary. That's why the irc folks were advising to not worry about it unless you see a problem coming up that the profiles points here.

Reply via email to