Avoid function calls in the loop condition of a for statement