scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit fd8c907050d89f2c6bbcd0d792ae5a0fc8a72b0d
parent 68746484af7bee6078b7516cc19a85ff861f98c3
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon, 10 Mar 2014 22:18:23 +0100

Set tok field of identifiers in lookup

This patch avoids one comparation for every identifier.

Diffstat:
Mlex.c | 2--
Msymbol.c | 3++-
2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/lex.c b/lex.c @@ -184,8 +184,6 @@ iden(void) ungetc(ch, yyin); yyval = lookup(yytext, NS_IDEN); - if (!yyval->tok) - yyval->tok = IDEN; return yyval->tok; } diff --git a/symbol.c b/symbol.c @@ -5,6 +5,7 @@ #include "cc.h" #include "symbol.h" +#include "tokens.h" #define NR_SYM_HASH 32 @@ -87,7 +88,7 @@ lookup(register const char *s, signed char ns) sym->next = head; sym->ctx = curctx; sym->ns = ns; - sym->tok = 0; + sym->tok = IDEN; head = sym; sym->hash = htab[key]; htab[key] = sym;