我有以下周期:
//condition will be set here to true or false
for (int i = 0; i < LARGE_NUMBER; i++) {
if (condition) {
//do foo
} else {
//do bar
}
}
Run Code Online (Sandbox Code Playgroud)
假设:没有条件而不是条件的周期更快.(这是真的吗?)问题:请问gcc if是否因为我condition已经设置了,如果已经设置了for循环,那么循环本身不会触及condition?
如果没有,我应该切换if和for重复代码,违反DRY等.