diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index a8a22e2f2..e18753fd5 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -23,6 +23,8 @@ EvalState::EvalState() initNixExprHelpers(); addPrimOps(); + + cacheTerms = getEnv("NIX_TERM_CACHE", "1") == "1"; } @@ -730,6 +732,8 @@ Expr evalExpr(EvalState & state, Expr e) state.nrEvaluated++; + if (!state.cacheTerms) return evalExpr2(state, e); + /* Consult the memo table to quickly get the normal form of previously evaluated expressions. */ Expr nf = state.normalForms.get(e); diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh index 5699d455c..db3bcadc6 100644 --- a/src/libexpr/eval.hh +++ b/src/libexpr/eval.hh @@ -38,6 +38,8 @@ struct EvalState unsigned int nrEvaluated; unsigned int nrCached; + bool cacheTerms; + EvalState(); void addPrimOps();