From b2feecf7e72728199920d93835c70530ddd07322 Mon Sep 17 00:00:00 2001 From: Jade Lovelace Date: Thu, 18 Dec 2025 18:38:38 +0100 Subject: [PATCH] libexpr: use MaintainCount for call depth This was duplicate code. Change-Id: I40697da80c3b8123c9cc3f10e5be5cc49c35629d --- lix/libexpr/eval.cc | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index c084c9add..f438d501b 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -1532,21 +1532,6 @@ void ExprLambda::eval(EvalState & state, Env & env, Value & v) v = {NewValueAs::lambda, state.ctx.mem, env, *this}; } -namespace { -/** Increments a count on construction and decrements on destruction. - */ -class CallDepth { - size_t & count; -public: - CallDepth(size_t & count) : count(count) { - ++count; - } - ~CallDepth() { - --count; - } -}; -}; - struct FormalsMatch { std::vector missing; @@ -1686,7 +1671,7 @@ void EvalState::callFunction(Value & fun, std::span args, Value & vRes, c { if (callDepth > evalSettings.maxCallDepth) ctx.errors.make("stack overflow; max-call-depth exceeded").atPos(pos).debugThrow(); - CallDepth _level(callDepth); + MaintainCount _level(callDepth); auto trace = evalSettings.traceFunctionCalls ? std::make_unique(ctx.positions[pos])