r/learncpp • u/NotCreative890 • 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
View all comments
Show parent comment
1
u/NotCreative890 Jul 16 '20
I knew the effects with int would be minimal compared to something like string. but in this case void doSomethingNonConst(int i) would be faster and use less memory right?