R
Richard Cavell
I have a recursive function like this:
void MyFunction(int i)
{
i++;
// do something with i
if (we're not finished) MyFunction(i);
}
I keep count of how far nested we are with i. Now, it would give the
compiler more chances at optimisation if I could give each loop its own
block of code, like this:
void MyFunctionNextedThrice()
{
// do something with the number two
// if (we're not finished) MyFunctionNestedFourTimes();
}
void MyFunctionNestedTwice()
{
// do something with the number zero
// if (we're not finished) MyFunctionNestedThrice();
}
void MyFunctionNextedOnce()
{
// do something with the number one
// if (we're not finished) MyFunctionNestedTwice();
}
void MyFunction()
{
// do something with the number zero
// if (we're not finished) MyFunctionNestedOnce();
}
What would be orgasmic is if I could 'inline' them inside each other.
Is there some way of creating a template (not in the C++ sense)? Do I
use macros (which, as the FAQ points out, are evil)?
void MyFunction(int i)
{
i++;
// do something with i
if (we're not finished) MyFunction(i);
}
I keep count of how far nested we are with i. Now, it would give the
compiler more chances at optimisation if I could give each loop its own
block of code, like this:
void MyFunctionNextedThrice()
{
// do something with the number two
// if (we're not finished) MyFunctionNestedFourTimes();
}
void MyFunctionNestedTwice()
{
// do something with the number zero
// if (we're not finished) MyFunctionNestedThrice();
}
void MyFunctionNextedOnce()
{
// do something with the number one
// if (we're not finished) MyFunctionNestedTwice();
}
void MyFunction()
{
// do something with the number zero
// if (we're not finished) MyFunctionNestedOnce();
}
What would be orgasmic is if I could 'inline' them inside each other.
Is there some way of creating a template (not in the C++ sense)? Do I
use macros (which, as the FAQ points out, are evil)?