diff options
author | Pamplemousse <xav.maso@gmail.com> | 2021-07-21 15:31:08 -0700 |
---|---|---|
committer | Pamplemousse <xav.maso@gmail.com> | 2021-07-21 16:49:52 -0700 |
commit | c1c5dd7449d54dbec48dccd26f3b3fb09e26b290 (patch) | |
tree | f61e568a6032ac91a4bec9c7a0c50b87fea99334 /src/libexpr/eval.cc | |
parent | 3bb8667a1758ad10b5f8621f7e187c38c9c860c0 (diff) |
Avoid global counters
Signed-off-by: Pamplemousse <xav.maso@gmail.com>
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r-- | src/libexpr/eval.cc | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index c3206a577..419b377ba 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -854,39 +854,37 @@ Value * Expr::maybeThunk(EvalState & state, Env & env) } -unsigned long nrAvoided = 0; - Value * ExprVar::maybeThunk(EvalState & state, Env & env) { Value * v = state.lookupVar(&env, *this, true); /* The value might not be initialised in the environment yet. In that case, ignore it. */ - if (v) { nrAvoided++; return v; } + if (v) { state.nrAvoided++; return v; } return Expr::maybeThunk(state, env); } Value * ExprString::maybeThunk(EvalState & state, Env & env) { - nrAvoided++; + state.nrAvoided++; return &v; } Value * ExprInt::maybeThunk(EvalState & state, Env & env) { - nrAvoided++; + state.nrAvoided++; return &v; } Value * ExprFloat::maybeThunk(EvalState & state, Env & env) { - nrAvoided++; + state.nrAvoided++; return &v; } Value * ExprPath::maybeThunk(EvalState & state, Env & env) { - nrAvoided++; + state.nrAvoided++; return &v; } @@ -1141,8 +1139,6 @@ static string showAttrPath(EvalState & state, Env & env, const AttrPath & attrPa } -unsigned long nrLookups = 0; - void ExprSelect::eval(EvalState & state, Env & env, Value & v) { Value vTmp; @@ -1154,7 +1150,7 @@ void ExprSelect::eval(EvalState & state, Env & env, Value & v) try { for (auto & i : attrPath) { - nrLookups++; + state.nrLookups++; Bindings::iterator j; Symbol name = getName(i, state, env); if (def) { |