ADVIL - Avoid Declaring Variables Inside Loops

This rule recommends to declare local variables outside the loops. The reason: as a rule, declaring variables inside the loop is less efficient.

Wrong

`int good_var = 0;
for (int i = 0; i < 100; i++) {
int var1 = 0;
// ...
}
while (true) {
int var2 = 0;
// ...
}
do {
int var3 = 0;
// ...
} while (true);`

Tip: Move variable declarations out of loop

Right

`int good_var = 0;
int var1;
for (int i = 0; i < 100; i++) {
var1 = 0;
// ...
}
int var2;
while (true) {
var2 = 0;
// ...
}
int var3;
do {
var3 = 0;
// ...
} while (true);`