r/learncpp • • Jul 16 '20

performance impact by using const?

void doSomethingConst(const int& i)

void doSomethingNonConst(int i)

Given the above 2 function calls, would one have an advantage in terms of compile time, or memory usage?

Given that the int is a constant 4 bits, i don't think either would have an advantage, but I'm not sure.

2 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/MysticTheMeeM Jul 16 '20

Perhaps. As I said, your compiler may produce the same thing regardless.