shithub: scc

Download patch

ref: fd8c907050d89f2c6bbcd0d792ae5a0fc8a72b0d
parent: 68746484af7bee6078b7516cc19a85ff861f98c3
author: Roberto E. Vargas Caballero <[email protected]>
date: Mon Mar 10 18:18:23 EDT 2014

Set tok field of identifiers in lookup

This patch avoids one comparation for every identifier.

--- a/lex.c
+++ b/lex.c
@@ -184,8 +184,6 @@
 	ungetc(ch, yyin);
 
 	yyval = lookup(yytext, NS_IDEN);
-	if (!yyval->tok)
-		yyval->tok = IDEN;
 	return yyval->tok;
 }
 
--- 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 @@
 	sym->next = head;
 	sym->ctx = curctx;
 	sym->ns = ns;
-	sym->tok = 0;
+	sym->tok = IDEN;
 	head = sym;
 	sym->hash = htab[key];
 	htab[key] = sym;