scc

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

commit fae3ad2774b0663dc508cc9c8ac9f671fd2abc83
parent 49121885af59183def0534697a2414733ac881cf
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 22 Dec 2016 15:18:11 +0100

[cc1] Remove linksym()

This function was used only in newsym() and this new form
makes the code more readable and compact.

Diffstat:
Mcc1/symbol.c | 29++++++++++-------------------
1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/cc1/symbol.c b/cc1/symbol.c @@ -136,23 +136,6 @@ newid(void) return id; } -static Symbol * -linksym(Symbol *sym) -{ - Symbol *p, *prev; - - switch (sym->ns) { - case NS_CPP: - return sym; - case NS_LABEL: - sym->next = labels; - return labels = sym; - default: - sym->next = head; - return head = sym; - } -} - Symbol * newsym(int ns, char *name) { @@ -169,8 +152,16 @@ newsym(int ns, char *name) sym->flags = 0; sym->u.s = NULL; sym->type = NULL; - sym->next = sym->hash = NULL; - return linksym(sym); + sym->hash = NULL; + + if (ns == NS_LABEL) { + sym->next = labels; + labels = sym; + } else if (ns != NS_CPP) { + sym->next = head; + head = sym; + } + return sym; } static Symbol *