diff options
Diffstat (limited to 'libcpp/lex.c')
-rw-r--r-- | libcpp/lex.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/libcpp/lex.c b/libcpp/lex.c index a7d988b..37df6ef 100644 --- a/libcpp/lex.c +++ b/libcpp/lex.c @@ -470,22 +470,36 @@ static cpp_hashnode * lex_identifier (cpp_reader *pfile, const uchar *base) { cpp_hashnode *result; - const uchar *cur; + const uchar *cur, *limit; + unsigned int len; + unsigned int hash = HT_HASHSTEP (0, *base); - do + cur = pfile->buffer->cur; + for (;;) { - cur = pfile->buffer->cur; - /* N.B. ISIDNUM does not include $. */ while (ISIDNUM (*cur)) - cur++; + { + hash = HT_HASHSTEP (hash, *cur); + cur++; + } pfile->buffer->cur = cur; + if (!forms_identifier_p (pfile, false)) + break; + + limit = pfile->buffer->cur; + while (cur < limit) + { + hash = HT_HASHSTEP (hash, *cur); + cur++; + } } - while (forms_identifier_p (pfile, false)); + len = cur - base; + hash = HT_HASHFINISH (hash, len); result = (cpp_hashnode *) - ht_lookup (pfile->hash_table, base, cur - base, HT_ALLOC); + ht_lookup_with_hash (pfile->hash_table, base, len, hash, HT_ALLOC); /* Rarely, identifiers require diagnostics when lexed. */ if (__builtin_expect ((result->flags & NODE_DIAGNOSTIC) |