diff options
author | Zack Weinberg <zack@gcc.gnu.org> | 2000-07-18 00:59:49 +0000 |
---|---|---|
committer | Zack Weinberg <zack@gcc.gnu.org> | 2000-07-18 00:59:49 +0000 |
commit | 711b88243b220e3cd737696da51de70f32bb7d5c (patch) | |
tree | a8929adb35764d62c4016b482a4cb4b619be00cb /gcc/cpplex.c | |
parent | 5d8fcdcb2ddbd52a35621a7880cf268c50a54027 (diff) | |
download | gcc-711b88243b220e3cd737696da51de70f32bb7d5c.zip gcc-711b88243b220e3cd737696da51de70f32bb7d5c.tar.gz gcc-711b88243b220e3cd737696da51de70f32bb7d5c.tar.bz2 |
[multiple changes]
2000-02-17 Zack Weinberg <zack@wolery.cumb.org>
* cpphash.c: Don't include hashtab.h. Most macro-handling code
moved to cppmacro.c.
(hash_HASHNODE, eq_HASHNODE, _cpp_dump_macro_hash,
dump_hash_helper): Delete.
(expand_hash, higher_prime_number, _cpp_lookup_with_hash,
cpp_forall_identifiers): New. Implement specialized version of
Vlad's expandable hash table.
(cpp_lookup): Use new functions.
(_cpp_init_macros, _cpp_cleanup_macros): Adjust for new
implementation.
* cppmacro.c: New file.
* cppinit.c (dump_macros_helper): New.
(cpp_finish): Iterate over the identifier table directly.
* cpplex.c (parse_name): Calculate the hash of the identifier
while we scan it. Use _cpp_lookup_with_hash when we can.
* cpphash.h: Update prototypes.
(xcnewvec, HASHSTEP): New helper macros.
* cpplib.h: Update prototypes.
* Makefile.in (LIBCPP_OBJS): Add cppmacro.o.
(cppmacro.o): New rule.
(cpphash.o): Update deps.
* cppmain.c: Do not set pfile->printer if no_output is on.
2000-02-15 Neil Booth <neilb@earthling.net>
* cpplib.c: Change all directive-handler functions to return
void, not int.
* cpphash.h: Update typedefs.
From-SVN: r35113
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r-- | gcc/cpplex.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c index fe337c0..a41e4ee 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -1070,16 +1070,21 @@ skip_whitespace (pfile, in_directive) } } -/* Parse (append) an identifier. */ +/* Parse (append) an identifier. Calculates the hash value of the + token while parsing, for performance. The algorithm *must* match + cpp_lookup(). */ static const U_CHAR * parse_name (pfile, tok, cur, rlimit) cpp_reader *pfile; cpp_token *tok; const U_CHAR *cur, *rlimit; { - const U_CHAR *name = cur; + const U_CHAR *name; unsigned int len; + unsigned int r; + name = cur; + r = 0; while (cur < rlimit) { if (! is_idchar (*cur)) @@ -1092,21 +1097,23 @@ parse_name (pfile, tok, cur, rlimit) CPP_BUFFER (pfile)->cur = cur; cpp_pedwarn (pfile, "'$' character in identifier"); } + + r = HASHSTEP (r, cur); cur++; } len = cur - name; - if (tok->val.node) + if (tok->val.node == 0) + tok->val.node = _cpp_lookup_with_hash (pfile, name, len, r); + else { unsigned int oldlen = tok->val.node->length; U_CHAR *newname = alloca (oldlen + len); memcpy (newname, tok->val.node->name, oldlen); memcpy (newname + oldlen, name, len); - len += oldlen; - name = newname; + tok->val.node = cpp_lookup (pfile, newname, len + oldlen); } - tok->val.node = cpp_lookup (pfile, name, len); return cur; } |