0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-10-10 00:25:06 -04:00

Use an explicit table for tolower() to avoid a function call

On some platforms, tolower() is implemented as a function call, in
order to handle locale support.  We never change locales, so can the
result of tolower() into a table, so we don't have to sit through the
function call every time.

~1.3% overall performance improvement on a macro-heavy benchmark under
Linux x86-64.
This commit is contained in:
H. Peter Anvin
2008-06-11 15:49:41 -07:00
parent 7b471fada8
commit ac8f8fcb27
7 changed files with 33 additions and 9 deletions

View File

@@ -175,6 +175,14 @@ void standard_extension(char *inname, char *outname, char *extension,
#define elements(x) ( sizeof(x) / sizeof(*(x)) )
/*
* tolower table -- avoids a function call on some platforms.
* NOTE: unlike the tolower() function in ctype, EOF is *NOT*
* a permitted value, for obvious reasons.
*/
void tolower_init(void);
extern unsigned char nasm_tolower_tab[256];
#define nasm_tolower(x) nasm_tolower_tab[(unsigned char)(x)]
/*
* some handy macros that will probably be of use in more than one