summaryrefslogtreecommitdiff
path: root/crc64.c
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 /crc64.c
parent7b471fada8697930e4bdaff50fe51caa2798815f (diff)
downloadnasm-ac8f8fcb27a063fbf7ec3ad3de18f6586e9e95b8.tar.gz
nasm-ac8f8fcb27a063fbf7ec3ad3de18f6586e9e95b8.tar.bz2
nasm-ac8f8fcb27a063fbf7ec3ad3de18f6586e9e95b8.zip
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 'crc64.c')
-rw-r--r--crc64.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/crc64.c b/crc64.c
index fc165b7..e8639c8 100644
--- a/crc64.c
+++ b/crc64.c
@@ -1,6 +1,5 @@
#include "compiler.h"
-#include <inttypes.h>
-#include <ctype.h>
+#include "nasmlib.h"
static const uint64_t crc64_tab[256] = {
UINT64_C(0x0000000000000000), UINT64_C(0x7ad870c830358979),
@@ -149,8 +148,7 @@ uint64_t crc64i(uint64_t crc, const char *str)
uint8_t c;
while ((c = *str++) != 0) {
- c = tolower(c);
- crc = crc64_tab[(uint8_t)crc ^ c] ^ (crc >> 8);
+ crc = crc64_tab[(uint8_t)crc ^ nasm_tolower(c)] ^ (crc >> 8);
}
return crc;