AFAIK if you do your length calculation in the For line, it still recalculates on each iteration which has a penalty. You should also avoid declaring variables within your loop body or calling outside functions when you can.
3 Likes