1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 10:41:16 +02:00

* Optimise null-ary term builders. Also declare all term builder

functions as pure, which might improve performance a bit.
This commit is contained in:
Eelco Dolstra 2006-05-02 21:58:46 +00:00
parent 68174bdc7d
commit d300b4383d
3 changed files with 16 additions and 7 deletions

View file

@ -6,8 +6,6 @@
EvalState::EvalState()
: normalForms(32768, 50)
{
blackHole = makeBlackHole();
nrEvaluated = nrCached = 0;
initNixExprHelpers();
@ -490,14 +488,14 @@ Expr evalExpr(EvalState & state, Expr e)
previously evaluated expressions. */
Expr nf = state.normalForms.get(e);
if (nf) {
if (nf == state.blackHole)
if (nf == makeBlackHole())
throw Error("infinite recursion encountered");
state.nrCached++;
return nf;
}
/* Otherwise, evaluate and memoize. */
state.normalForms.set(e, state.blackHole);
state.normalForms.set(e, makeBlackHole());
try {
nf = evalExpr2(state, e);
} catch (Error & err) {
@ -536,5 +534,4 @@ void printEvalStats(EvalState & state)
% state.nrEvaluated % state.nrCached
% ((float) state.nrCached / (float) state.nrEvaluated * 100)
% AT_calcAllocatedSize());
sleep(100);
}