shithub: scc

Download patch

ref: ca3407661071828c8ebac7b66e1eb975a7b5743c
parent: 8cd0cd7c7f5ae4003bcb9e95cd8e3f81a63d30a3
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Dec 22 10:18:11 EST 2016

[cc1] Remove linksym()

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

--- a/cc1/symbol.c
+++ b/cc1/symbol.c
@@ -136,23 +136,6 @@
 	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 @@
 	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 *