From 695b447ead5de61d067bda4dcf438fd014a91ca2 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 7 Oct 2009 00:04:50 +0000 Subject: Remove double lookup. git-svn-id: http://svn.drobilla.net/resp/tuplr@203 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/constrain.cpp | 5 ++--- src/tuplr.hpp | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/constrain.cpp b/src/constrain.cpp index bdabc52..6f68b4c 100644 --- a/src/constrain.cpp +++ b/src/constrain.cpp @@ -149,14 +149,13 @@ AFn::constrain(TEnv& tenv, Constraints& c) const at(i)->constrain(tenv, cp); AType* bodyT = tenv.var(at(e-1)); - Subst tsubst = unify(cp); + subst = unify(cp); genericType = tup(loc, tenv.penv.sym("Fn"), - tsubst.apply(protT), tsubst.apply(bodyT), 0); + subst.apply(protT), subst.apply(bodyT), 0); tenv.genericTypes.insert(make_pair(this, genericType)); Object::pool.addRoot(genericType); tenv.pop(); - subst = tsubst; } AType* t = new AType(*genericType); // FIXME: deep copy diff --git a/src/tuplr.hpp b/src/tuplr.hpp index 541e24b..a76f039 100644 --- a/src/tuplr.hpp +++ b/src/tuplr.hpp @@ -571,7 +571,6 @@ inline ostream& operator<<(ostream& out, const Constraints& c) { struct TEnv : public Env< const ASymbol*, pair > { TEnv(PEnv& p) : penv(p), varID(1) {} AType* fresh(const ASymbol* sym) { - assert(sym); AType* ret = new AType(sym->loc, varID++); def(sym, make_pair((AST*)NULL, ret)); return ret; @@ -579,7 +578,7 @@ struct TEnv : public Env< const ASymbol*, pair > { AType* var(const AST* ast=0) { const ASymbol* sym = ast->to(); if (sym) - return deref(lookup(sym)).second; + return ref(sym)->second; Vars::iterator v = vars.find(ast); if (v != vars.end()) -- cgit v1.2.1