Here is a fragment of code:
bool EqualsA(const Foo& a, const Foo& b)
{
return a == b;
}
bool EqualsB(const Foo& a, const Foo& b)
{
const bool result = a == b;
return result;
}
int MethodA()
{
return GetValue() * GetOtherValue();
}
int MethodB()
{
const int result = GetValue() * GetOtherValue();
return result;
}
I wanted to know if there is any difference in returning values in these two different ways (instant return or store result in a variable). I think that storing is better for debugging but is there any performance loss (I don't think there is) or any other pros and cons for using one of those.