while(true) versus for(;;) [duplicate]
Possible Duplicates:
Is “for(;;)” faster than “while (TRUE)”? If not, why do people use it? for ( ; ; ) or while ( true ) - Which is t开发者_JAVA百科he Correct C# Infinite Loop?
Is there any appreciable difference between while(true)
(or while(1)
) and for(;;)
? Would there be any reason to choose one over the other?
With optimizations enabled, they will compile identically.
You should use whichever one you find more readable.
No. I think for(;;)
looks nicer. But they're the same.
Also see Is "for(;;)" faster than "while (TRUE)"? If not, why do people use it?
精彩评论