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