about summary refs log tree commit diff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2006-05-02T21·39+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2006-05-02T21·39+0000
commit68174bdc7d68746c5471e87bb74909c552e98644 (patch)
treebaba7c3cffba029f50dd20934ec490ae9d8fa255 /src/libexpr/eval.cc
parentc791e94aee07ad98ec29df18498ad85241e1e96d (diff)
* Use a linked list of substitutions. This reduces the amount of
  copying.

Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc11
1 files changed, 7 insertions, 4 deletions
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);
 }