lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Mail from: From: leiradella@bigfoot.com

> This will only produce a tiny improvement, but switch is your friend: 
> 
>     if (key[0] != '\0') 
>     { 
>          switch (key[0] | (key[1] << 8)) 
>          { 
>               case 'x': 
>                    /* do X thing */ 
>                    break; 
> 
>               case 'y': 
>                    /* do Y thing */ 
>                    break; 
>          } 
>     } 

Depending on how many keys one have to compare and their difference in 
length, gperf (http://www.gnu.org/software/gperf/gperf.html) can also be a 
good friend. 

Andre de Leiradella