PreviousNext
Default is first at switch
Help > Appendix > Code Optimization > Default is first at switch

FLASH-                        RAM                Speed+

 

If there is a default used inside the switch then it should be the first “case“to avoid internal “goto default” instruction. It might in some cases produce shorter and faster code.

 

switch ( DLEN )

{

  case 12:

       return 21;

 

  case 34:

       return 43;

 

  default:

       return 0;

}

switch ( DLEN )

{

  default:

       return 0;

 

  case 12:

       return 21;

 

  case 34:

       return 43;

}