On 7/30/07, Dinesh Joshi dinesh.a.joshi@gmail.com wrote:
All I can see is that the first example can have only 1 condition while the other blcok can break over several conditions. Care to explain in more detail so that your dilemma is more clear in everyone's mind?
Ok I guess the confusion is because I posted two queries without explicitly detailing them. The code posted below is in C/C++. Here they are:
1) Which is more efficient, or is there no difference between them:
while(true) { ... if(condition) break; }
OR
while(condition) { ... }
2) Does this code only look bad or does it execute slowly as well:
while(true) { if(condition1) { do_something; break; } if(condition2) { do_something; break; }
do_something;
break; }
Apologies for causing the confusion.