diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2021-11-24 20:21:34 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2021-11-25 16:31:39 +0100 |
commit | b6c8e57056f81fa3c2827a7fdc6f335ec54727bd (patch) | |
tree | 5339262007e54fb12a7c1fdce3d2fa30147534db /src/libexpr/primops/context.cc | |
parent | ca82967ee3276e2aa8b02ea7e6d19cfd4fa75f4c (diff) |
Support range-based for loop over list values
Diffstat (limited to 'src/libexpr/primops/context.cc')
-rw-r--r-- | src/libexpr/primops/context.cc | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/libexpr/primops/context.cc b/src/libexpr/primops/context.cc index 31cf812b4..20545afd0 100644 --- a/src/libexpr/primops/context.cc +++ b/src/libexpr/primops/context.cc @@ -118,9 +118,8 @@ static void prim_getContext(EvalState & state, const Pos & pos, Value * * args, auto & outputsVal = *state.allocAttr(infoVal, state.sOutputs); state.mkList(outputsVal, info.second.outputs.size()); size_t i = 0; - for (const auto & output : info.second.outputs) { + for (const auto & output : info.second.outputs) mkString(*(outputsVal.listElems()[i++] = state.allocValue()), output); - } } infoVal.attrs->sort(); } @@ -181,8 +180,8 @@ static void prim_appendContext(EvalState & state, const Pos & pos, Value * * arg .errPos = *i.pos }); } - for (unsigned int n = 0; n < iter->value->listSize(); ++n) { - auto name = state.forceStringNoCtx(*iter->value->listElems()[n], *iter->pos); + for (auto elem : iter->value->listItems()) { + auto name = state.forceStringNoCtx(*elem, *iter->pos); context.insert("!" + name + "!" + string(i.name)); } } |