From 68174bdc7d68746c5471e87bb74909c552e98644 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 2 May 2006 21:39:02 +0000 Subject: * Use a linked list of substitutions. This reduces the amount of copying. --- src/libexpr/eval.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/libexpr/eval.cc') diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 384d87a269ee..1ee9da3b9bc8 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -71,7 +71,7 @@ static Expr substArgs(Expr body, ATermList formals, Expr arg) throw Error(format("required function argument `%1%' missing") % aterm2String(*i)); - return substitute(subs, body); + return substitute(Substitution(0, &subs), body); } @@ -97,11 +97,13 @@ ATerm expandRec(ATerm e, ATermList rbnds, ATermList nrbnds) subs.set(name, e2); } + Substitution subs_(0, &subs); + /* Create the non-recursive set. */ ATermMap as; for (ATermIterator i(rbnds); i; ++i) { if (!matchBind(*i, name, e2, pos)) abort(); /* can't happen */ - as.set(name, makeAttrRHS(substitute(subs, e2), pos)); + as.set(name, makeAttrRHS(substitute(subs_, e2), pos)); } /* Copy the non-recursive bindings. !!! inefficient */ @@ -344,7 +346,7 @@ Expr evalExpr2(EvalState & state, Expr e) try { ATermMap subs; subs.set(name, e2); - return evalExpr(state, substitute(subs, e4)); + return evalExpr(state, substitute(Substitution(0, &subs), e4)); } catch (Error & e) { e.addPrefix(format("while evaluating the function at %1%:\n") % showPos(pos)); @@ -402,7 +404,7 @@ Expr evalExpr2(EvalState & state, Expr e) throw; } try { - e2 = substitute(attrs, e2); + e2 = substitute(Substitution(0, &attrs), e2); checkVarDefs(state.primOps, e2); return evalExpr(state, e2); } catch (Error & e) { @@ -534,4 +536,5 @@ void printEvalStats(EvalState & state) % state.nrEvaluated % state.nrCached % ((float) state.nrCached / (float) state.nrEvaluated * 100) % AT_calcAllocatedSize()); + sleep(100); } -- cgit 1.4.1