Despite all the well-known blogs about this problem, I always doubt some of the results, and my personal tests show that the well-known standard is not the best.
Declaring variables inside a loop so that they are close to its size and speed up its access to this method, but allocating more memory or declaring out of scope for , to preserve memory allocation, but increase processing for iteration in a remote instance.
My results show that method B is faster (sometimes), I want to know the background around this.
resultschange, and they are not a guru pavers.
And what do you guys think about this?
Method a
var object:Object = new Object();
var loop:int = 100000
for (var i:int = 0; i < loop; i++)
{
object = new Object();
object.foo = foo;
object.bar = bar;
}
OR
Method B
var loop:int = 100000
for (var i:int = 0; i < loop; i++)
{
var object:Object = new Object()
object.foo = foo;
object.bar = bar;
}
source