PreviousNext
do {} while () is preferred
Help > Appendix > Code Optimization > do {} while () is preferred

FLASH-                        RAM                Speed+

 

If possible do {} while () should be used instead of while( ){} or for(;;) {} because a jump from the end of the loop is not needed and the condition is evaluated one less time.

 

uns8 loop = 12;

while ( loop != 0 )

{

  // use loop

  loop -= 3;

}

uns8 loop = 12;

do

{

  // use loop

  loop -= 3;

}

while ( loop != 0 );