you can just do this test once outside of loop. Not sure how expensive it is, but since it's invariable, no need to perform it multiple times.