나는이 같았다 코드의 조각을했다 :비 사소한 고토 사용 (컴파일러 이길 수)
f += .001f; //Only needs to be executed when loop executes at least one iteration, but does no harm if incremented without entering the loop
while(anIndex < aVaryingBoundary) {
if(something) {
//code
continue;
}
//more code
}
이 코드보다 효율적으로 발견하는 유일한 방법 (F의 불필요한 증가를 제거하여) 고토를 사용했다.
if(anIndex < aVaryingBoundary) {
f += .001f;
loop:
if(something) {
//code
if(anIndex < aVaryingBoundary) {
goto loop;
}
else {
goto loop_end;
}
}
//more code
if(anIndex < aVaryingBoundary) {
goto loop;
}
}
loop_end:
단순한 최적화이지만 컴파일러가이를 쉽게 감지 할 수 있다고 생각하지 않습니다. 컴파일러가 수행하는 것이 그리 평범한가요?
왜 사용하는'goto' - 멀리 방주 –
대신의'if' 내부의'goto', 왜 그냥 추가 루프 갔던? –
어떻게 최적화합니까? – melpomene