Ignore:
Timestamp:
Aug 30, 2018, 10:26:27 PM (6 years ago)
Author:
viala@…
Message:

Rewrite if-then-else return function into switch case.

For safety reason and performance:

1) Safety: GCC complain with a warning if you forgot an enum variant.
2) code-gen just outperform naive if-then-else.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/devices/dev_txt.h

    r457 r527  
    7878 *****************************************************************************************/
    7979
    80 enum
     80typedef enum
    8181{
    8282    TXT_READ       = 0,
    8383    TXT_WRITE      = 1,
    8484    TXT_SYNC_WRITE = 2,
    85 };
     85} dev_txt_cmd_t;
    8686
    8787typedef struct txt_command_s
     
    113113 * @ type     : command type (TXT_READ / TXT_WRITE / TXT_SYNC_WRITE)
    114114 *****************************************************************************************/
    115 char * dev_txt_type_str( uint32_t type );
     115const char * dev_txt_type_str( dev_txt_cmd_t type );
    116116
    117117/******************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.