summaryrefslogtreecommitdiff
path: root/nasmlib.h
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2008-06-11 15:49:41 -0700
committerH. Peter Anvin <hpa@zytor.com>2008-06-11 15:49:41 -0700
commitac8f8fcb27a063fbf7ec3ad3de18f6586e9e95b8 (patch)
treed4315e0d8a8c6d27d0883aa67461251ce4bbc59e /nasmlib.h
parent7b471fada8697930e4bdaff50fe51caa2798815f (diff)
downloadnasm-ac8f8fcb27a063fbf7ec3ad3de18f6586e9e95b8.tar.gz
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.
Diffstat (limited to 'nasmlib.h')
-rw-r--r--nasmlib.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/nasmlib.h b/nasmlib.h
index 837d679c..7391564c 100644
--- a/nasmlib.h
+++ b/nasmlib.h
@@ -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