开发者

while(true) versus for(;;) [duplicate]

开发者 https://www.devze.com 2023-01-18 07:01 出处:网络
This question already has answers here: Closed 12 years ago. Possible Duplicates: Is “for(;;)”faster than “while (TRUE)”? If not, why do people use it?
This question already has answers here: Closed 12 years ago.

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消