Simplest example to highlight the difference:
int foo()
{
doSomething();
return 0;
}
void bar()
{
doSomething();
return;
}
int main()
{
foo();
bar();
}
Is bar faster than foo, and why?
This is such a micro optimization that you should never have to even consider it. Yet the usual caveats when talking about performance:
As of the particular case of returning a small object (something that fits in a register), the cost is going to be negligible, basically a load into a register in most architectures.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With