libexpr: Migrate EvalState::concatLists to return a Value

Part of #1136

Change-Id: Ie28ee8456191b3da20d53e95ea49e0ec6a6a6964
This commit is contained in:
skye
2026-04-07 22:38:24 -04:00
parent c01bd37a8d
commit aed5b5cbce
3 changed files with 5 additions and 10 deletions
+3 -6
View File
@@ -1400,9 +1400,7 @@ Value EvalState::updateAttrs(const Value & v1, const Value & v2)
return v;
}
void EvalState::concatLists(
Value & v, std::span<Value> lists, const PosIdx pos, std::string_view errorCtx
)
Value EvalState::concatLists(std::span<Value> 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
+1 -2
View File
@@ -827,8 +827,7 @@ public:
Value & v);
Value updateAttrs(const Value & v1, const Value & v2);
void
concatLists(Value & v, std::span<Value> lists, const PosIdx pos, std::string_view errorCtx);
Value concatLists(std::span<Value> lists, const PosIdx pos, std::string_view errorCtx);
private:
+1 -2
View File
@@ -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"