diff options
| author | Linus Torvalds <torvalds@tove.osdl.org> | 2004-11-09 16:15:54 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-07 21:04:16 -0700 |
| commit | cf28080aff885f66e8c09920dabba0c421c83ade (patch) | |
| tree | c1dee3f720d12a5760b667d5489b0462f55b2b8f /tokenize.c | |
| parent | 4d383e59768817899d9bae2c72813680c7f2df17 (diff) | |
| download | sparse-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.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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; } |
