From aed5b5cbce27c5afd809ab8457742829e4a7c760 Mon Sep 17 00:00:00 2001 From: skye Date: Tue, 7 Apr 2026 20:02:58 -0400 Subject: [PATCH] libexpr: Migrate EvalState::concatLists to return a Value Part of #1136 Change-Id: Ie28ee8456191b3da20d53e95ea49e0ec6a6a6964 --- lix/libexpr/eval.cc | 9 +++------ lix/libexpr/eval.hh | 3 +-- lix/libexpr/primops.cc | 3 +-- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/lix/libexpr/eval.cc b/lix/libexpr/eval.cc index 75ccb0948..1f09cb802 100644 --- a/lix/libexpr/eval.cc +++ b/lix/libexpr/eval.cc @@ -1400,9 +1400,7 @@ Value EvalState::updateAttrs(const Value & v1, const Value & v2) return v; } -void EvalState::concatLists( - Value & v, std::span lists, const PosIdx pos, std::string_view errorCtx -) +Value EvalState::concatLists(std::span lists, const PosIdx pos, std::string_view errorCtx) { ctx.stats.nrListConcats++; @@ -1418,12 +1416,10 @@ void EvalState::concatLists( } if (nonEmpty && len == nonEmpty->listSize()) { - v = *nonEmpty; - return; + return *nonEmpty; } auto list = ctx.mem.newList(len); - v = {NewValueAs::list, list}; auto out = list->elems; for (size_t n = 0, pos = 0; n < lists.size(); ++n) { auto l = lists[n].listSize(); @@ -1432,6 +1428,7 @@ void EvalState::concatLists( } pos += l; } + return {NewValueAs::list, list}; } // always force this to be separate, otherwise forceValue may inline it and take diff --git a/lix/libexpr/eval.hh b/lix/libexpr/eval.hh index d087a2e6b..0d86f8d69 100644 --- a/lix/libexpr/eval.hh +++ b/lix/libexpr/eval.hh @@ -827,8 +827,7 @@ public: Value & v); Value updateAttrs(const Value & v1, const Value & v2); - void - concatLists(Value & v, std::span lists, const PosIdx pos, std::string_view errorCtx); + Value concatLists(std::span lists, const PosIdx pos, std::string_view errorCtx); private: diff --git a/lix/libexpr/primops.cc b/lix/libexpr/primops.cc index e1a76700a..12cb99ade 100644 --- a/lix/libexpr/primops.cc +++ b/lix/libexpr/primops.cc @@ -2367,8 +2367,7 @@ static void prim_elem(EvalState & state, Value * * args, Value & v) static void prim_concatLists(EvalState & state, Value * * args, Value & v) { state.forceList(*args[0], noPos, "while evaluating the first argument passed to builtins.concatLists"); - state.concatLists( - v, + v = state.concatLists( std::span{args[0]->listElems(), args[0]->listSize()}, noPos, "while evaluating a value of the list passed to builtins.concatLists"