I’ve always been told that we should not pass POD by reference. But recently I’ve discovered that a reference actually takes no memory at all.
So why do we choose to write:
void DoSomething(int iNumber);
instead of:
void DoSomething(const int& riNumber);
is it not more efficient?
Actually in this case (using int) passing by value is probably more efficient, since only 1 memory-read is needed instead of 2, to access the passed value.
Example (optimized using -O2):
Asm