shithub: mc

Download patch

ref: d7c4bac9357a6d5e3dfd691434f8d9a47d79f0dc
parent: 2fd7aa8d72729ccec6c611fb3586e9c4c7b5e067
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jul 15 11:00:11 EDT 2017

Inline remapping function.

	Easier to read, clearer what's going on.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -513,37 +513,25 @@
 	return t;
 }
 
-static Type *
-remapping(Type *t)
-{
-	Stab *ns;
-	Type *lu;
-
-	if (t->type != Tyunres)
-		return NULL;
-
-	ns = curstab();
-	if (t->name->name.ns)
-		ns = getns(file, t->name->name.ns);
-	if (!ns)
-		fatal(t->name, "no namespace \"%s\"", t->name->name.ns);
-	lu = gettype(ns, t->name);
-	if (!lu)
-		fatal(t->name, "no type %s", tystr(t));
-	return lu;
-}
-
 /* Look up the best type to date in the unification table, returning it */
 static Type *
 tylookup(Type *t)
 {
 	Type *lu;
+	Stab *ns;
 
 	assert(t != NULL);
 	lu = NULL;
 	while (1) {
-		if (!tytab[t->tid]) {
-			lu = remapping(t);
+		if (!tytab[t->tid] && t->type == Tyunres) {
+			ns = curstab();
+			if (t->name->name.ns)
+				ns = getns(file, t->name->name.ns);
+			if (!ns)
+				fatal(t->name, "no namespace \"%s\"", t->name->name.ns);
+			lu = gettype(ns, t->name);
+			if (!lu)
+				fatal(t->name, "no type %s", tystr(t));
 			if (lu && lu != t)
 				tytab[t->tid] = lu;
 		}