On 7/30/07, Dinesh Joshi dinesh.a.joshi@gmail.com wrote:
Hmm...well, it depends. The first block will break after executing some instructions. It actually looks like a Do...While loop since it executes instructions FIRST and then CHECKs the condition.
The second block first checks the condition and then executes the instructions. So it really depends on the specific code. The general blocks can't be compared really as they are NOT the same.
OK, but is it worth spending some time evaluating my construct to actually avoid the while(true)?
Actually that piece of code will execute only ONCE. Why? Because you have a break just before the closing brace of the while loop.
Yes it will execute only once; that was not a typo ;) I guess it is meant as a replacement for the try-catch block. I'm guessing the reason is that no optimization is done inside try-catch blocks since any call inside the try block may lead to a branch.