I see this style a lot in our code base and online as well, where if you have a function with for loops, and if statements, all the variables that only they use and nothing else are declared outside them. For example:
void process()
{
int i;
int count = 100;
vector3 point;
vector sum;
for (i = 0; i < count; ++i)
{
import(this, "pos", point);
sum += point;
}
sum /= count;
}
Or is this premature optimization? I am curious about it for C++, C# and Python which are the languages I use and where I saw these over and over again.