Hi
The forever macro in Qt is for(; .Is there any advantage of using while(true) to for(;.
Thanks.
Hi
The forever macro in Qt is for(; .Is there any advantage of using while(true) to for(;.
Thanks.
It's for efficiency. Compiler may generate more assembler instructions for while(true), because there is a judgment. However, if you leave the middle parameter of for( ; ; ) empty, compiler will generate a jump instruction without any judgment.
But, modern compiler should be capable to recognize the forever true parameter of while() and generate the same assembler instructions as for( ; ; ).
So, use both as you like.
Last edited by freezeblue; 13th June 2009 at 14:27.
babu198649 (15th June 2009), Petroz (28th September 2009)
Bookmarks