I didn't quite understand
There are two meanings one can derive from this statementQuote:
it is NEVER a good idea to jam a variable declaration into a for statement
Is "i" or "a" the jammed variable declaration? There is no reason why "i" is a bad idea since it is only created once and only exists for the duration of the loop. "a" is a bad idea because it calls the int constructor every time. Since the topic of conversation is the loop control variable and declarations with the loop body, why bring this up?Code:for (int i = 0; i < 1000; i++)
{
int a = b[i];
...
}
Anyway, in my younger days, the term jamming meant something else: it was a form of optimization i.e.
Code:// unoptimized loop
for (i = 0; i < 1000; i++)
a[i] = 0;
for (i = 0; i < 1000; i++)
b[i] = 1;
// Jammed loop
for (i = 0; i < 1000; i++)
{
a[i] = 0;
b[i] = 1;
}
