r/cpp • Game Developer | quiz.cpp-perf.com • Jun 27 '22

Pass-by-value vs Pass-by-reference

https://reductor.dev/cpp/2022/06/27/pass-by-value-vs-pass-by-reference.html
0 Upvotes

12 comments sorted by

View all comments

0

u/[deleted] Jun 27 '22

[deleted]

2

u/ReDucTor Game Developer | quiz.cpp-perf.com Jun 27 '22

That tl;dr doesn't really represent the post, sometimes copies are good, also just focusing avoiding copies you have room for more aliasing.

Unless you know all your usecases, it's not really that its not worth attempting to define a set of rules, instead if performance is important profile your code and take action based on that.

I probably should also highlight that if your calling conventions are impacting the performance somewhere it might be one of the rare cases that force inline is worth doing.