H
Hicham Mouline
Please refer to my previous post for presentation of the problem.
My question now is re how to actually write the code for
Calculate ( CalcCode codes[], double results[], const CalcOperations&
operations, int thing)
{
}
In practice, I see the operations map having as many as 30 operations.
There are groups of 4/5 operations that are tightly related, and when
operations within these groups
are requested within the same call of Calculate(), there is a perf benefit
by not having duplicate
execution of bits of code.
The structure of Calculate() is like:
{
if (operations.isSet(OP1))
{
.. .... // do length operation 1
// fill in results and codes
}
if (operations.isSet(OP2)) // tightly related to OP1
{
if (!operations.isSet(OP1))
{
// do length operation 1
}
// otherwise, lengthy operation 1 done already in the step before, not do
it again
}
This pattern might involve more than 3 or 4 operations in the if tests.
Is there a more elegant, shorter code way of writing this, but just as
efficient?
regards,
My question now is re how to actually write the code for
Calculate ( CalcCode codes[], double results[], const CalcOperations&
operations, int thing)
{
}
In practice, I see the operations map having as many as 30 operations.
There are groups of 4/5 operations that are tightly related, and when
operations within these groups
are requested within the same call of Calculate(), there is a perf benefit
by not having duplicate
execution of bits of code.
The structure of Calculate() is like:
{
if (operations.isSet(OP1))
{
.. .... // do length operation 1
// fill in results and codes
}
if (operations.isSet(OP2)) // tightly related to OP1
{
if (!operations.isSet(OP1))
{
// do length operation 1
}
// otherwise, lengthy operation 1 done already in the step before, not do
it again
}
This pattern might involve more than 3 or 4 operations in the if tests.
Is there a more elegant, shorter code way of writing this, but just as
efficient?
regards,