You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
state.forceList(*args[0], pos, "while evaluating the argument passed to builtins.listToAttrs");
2963
2963
2964
-
auto attrs = state.buildBindings(args[0]->listSize());
2964
+
// Step 1. Sort the name-value attrsets in place using the memory we allocate for the result
2965
+
size_t listSize = args[0]->listSize();
2966
+
auto & bindings = *state.allocBindings(listSize);
2967
+
using ElemPtr = decltype(&bindings[0].value);
2965
2968
2966
-
std::set<Symbol> seen;
2967
-
2968
-
for (auto v2 : args[0]->listItems()) {
2969
+
for (constauto & [n, v2] : enumerate(args[0]->listItems())) {
2969
2970
state.forceAttrs(*v2, pos, "while evaluating an element of the list passed to builtins.listToAttrs");
2970
2971
2971
2972
auto j = state.getAttr(state.sName, v2->attrs(), "in a {name=...; value=...;} pair");
2972
2973
2973
2974
auto name = state.forceStringNoCtx(*j->value, j->pos, "while evaluating the `name` attribute of an element of the list passed to builtins.listToAttrs");
2974
-
2975
2975
auto sym = state.symbols.create(name);
2976
-
if (seen.insert(sym).second) {
2977
-
auto j2 = state.getAttr(state.sValue, v2->attrs(), "in a {name=...; value=...;} pair");
2978
-
attrs.insert(sym, j2->value, j2->pos);
2979
-
}
2976
+
2977
+
// (ab)use Attr to store a Value * * instead of a Value *, so that we can stabilize the sort using the Value * *
0 commit comments