aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tokenize.c
diff options
authorLinus Torvalds <torvalds@tove.osdl.org>2004-11-09 16:15:54 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:04:16 -0700
commitcf28080aff885f66e8c09920dabba0c421c83ade (patch)
treec1dee3f720d12a5760b667d5489b0462f55b2b8f /tokenize.c
parent4d383e59768817899d9bae2c72813680c7f2df17 (diff)
downloadsparse-dev-cf28080aff885f66e8c09920dabba0c421c83ade.tar.gz
Optimize "create_hashed_ident()".
memcmp() tends to be optimized for all the wrong cases, so do the obvious expansion which allows the compiler to do the right thing.
Diffstat (limited to 'tokenize.c')
-rw-r--r--tokenize.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/tokenize.c b/tokenize.c
index 651b5a87..20b47fee 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -743,10 +743,20 @@ static struct ident *create_hashed_ident(const char *name, int len, unsigned lon
p = &hash_table[hash];
while ((ident = *p) != NULL) {
- if (ident->len == len && !memcmp(ident->name, name, len)) {
+ if (ident->len == (unsigned char) len) {
+ const char *n = name;
+ const char *m = ident->name;
+ do {
+ if (*n != *m)
+ goto next;
+ n++;
+ m++;
+ } while (--len);
+
ident_hit++;
return ident;
}
+next:
//misses++;
p = &ident->next;
}