PreviousNext
Using goto to avoid redundant code
Help > Appendix > Code Optimization > Using goto to avoid redundant code

FLASH-                        RAM                Speed-

 

CC5X is not able to detect and merge the same tailing code from more blocks that terminate at the same point. goto statement will help.

 

switch ( byte )

{

default:

  return TRUE;

 

case 0:

  variable = 0xbb;

  err = TRUE;

  disableSPI();

  return FALSE;

 

case 1:

  variable = 0xaa;

  err = TRUE;

  disableSPI();

  return FALSE;

}

switch ( byte )

{

default:

  return TRUE;

 

case 0:

  variable = 0xbb;

  goto LABEL;

 

case 1:

  variable = 0xaa;

LABEL:

  err = TRUE;

  disableSPI();

  return FALSE;

}