The variable is set once, but the if expression is still evaluated every time (unless the compiler can optimize it)
So there would be the branching overhead in every iteration. But that’s something the cpu branch prediction should cover, especially since the taken branch will be identical in every loop.
Same also applied to the implied condition to break the for loop (only the first few and last iteration should be wrong predictions)
The variable is set once, but the if expression is still evaluated every time (unless the compiler can optimize it)
So there would be the branching overhead in every iteration. But that’s something the cpu branch prediction should cover, especially since the taken branch will be identical in every loop.
Same also applied to the implied condition to break the for loop (only the first few and last iteration should be wrong predictions)