PreviousNext
Function call before return
Help > Appendix > Code Optimization > Function call before return

FLASH-                        RAM                Speed+

 

If the very last function statement is another function (from the same page) call, then CC5X uses efficiently goto instead of call+return. It is faster, shorter, and consumes less MCU stack.

 

void Method ()

{

  disableSPI();

  variable = 0;

}

void Method ()

{

  variable = 0;

  disableSPI();

}

 

void Method ()

{

  if ( enable )

       enableSPI();

  else

       disableSPI();

}

void Method ()

{

  if ( enable )

  {

       enableSPI();

       // return forces CC5X to emit BRA/GOTO before           // else instead of CALL

       return;

  }

  else

       disableSPI();

}