This is a c++ coding problem.
if (condition)
initialize arg2;
for loop
{
if (condition)
f(arg1, arg2[loop_index]);
else
f(arg1, 0);
}
How to combine the if()
to call f()
only one time ?
arg2 may consume a lot of memory, if condition is false, we do not need to initialize it.
Any help will be appreciated.