In an interview test, for the following code :
void GetPosition(dummyClass& a, dummyClass& b) {
a = GetOrigin();
b = a + GetAxis().ToForward() * distance;
}
The interviewer wrote the following comment :
If you return value using out argument then don't use the arguments inside the function, the compiler will generally write the variables to memory and read it right back from memory. Use a local stack variable, this allows the compiler to optimize better and only write the data to memory when absolutely needed.
I never heard about the fact that I should avoid using reference parameters inside the function. Is that a common practice when doing C++, or some really specific optimization? And if so, is there some specific documentation that I could read that would cover that case?