about summary refs log tree commit diff
path: root/third_party/nix/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-12-22T20·51+0100
committertazjin <mail@tazj.in>2020-12-23T11·33+0000
commitf7ea650142eb796eb3f2827c805cc0bc563e2183 (patch)
tree2d451749e40e0278aac89fe38dcbfa72015ccb95 /third_party/nix/src/libexpr/primops.cc
parent0f9a7b3f86f56162cf1a694d98d82e4937d44a52 (diff)
refactor(tvix/libexpr): Remove Bindings::SortedByKeys() r/2028
Since we don't have a Bindings implementation with unstable order this
function is not required, as its callers can just iterate over the
attributes instead.

Change-Id: I01b35277b5a2dde69d684bc881dbd7c0701bcbb3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2291
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to '')
-rw-r--r--third_party/nix/src/libexpr/primops.cc68
1 files changed, 34 insertions, 34 deletions
diff --git a/third_party/nix/src/libexpr/primops.cc b/third_party/nix/src/libexpr/primops.cc
index 0bac7793c7..49c43556fe 100644
--- a/third_party/nix/src/libexpr/primops.cc
+++ b/third_party/nix/src/libexpr/primops.cc
@@ -510,11 +510,11 @@ static void prim_derivationStrict(EvalState& state, const Pos& pos,
   StringSet outputs;
   outputs.insert("out");
 
-  for (auto& i : args[0]->attrs->SortedByKeys()) {
-    if (i->name == state.sIgnoreNulls) {
+  for (auto& [_, i] : *args[0]->attrs) {
+    if (i.name == state.sIgnoreNulls) {
       continue;
     }
-    const std::string& key = i->name;
+    const std::string& key = i.name;
 
     auto handleHashMode = [&](const std::string& s) {
       if (s == "recursive") {
@@ -556,19 +556,19 @@ static void prim_derivationStrict(EvalState& state, const Pos& pos,
 
     try {
       if (ignoreNulls) {
-        state.forceValue(*i->value);
-        if (i->value->type == tNull) {
+        state.forceValue(*i.value);
+        if (i.value->type == tNull) {
           continue;
         }
       }
 
       /* The `args' attribute is special: it supplies the
          command-line arguments to the builder. */
-      if (i->name == state.sArgs) {
-        state.forceList(*i->value, pos);
-        for (unsigned int n = 0; n < i->value->listSize(); ++n) {
-          std::string s = state.coerceToString(
-              posDrvName, *(*i->value->list)[n], context, true);
+      if (i.name == state.sArgs) {
+        state.forceList(*i.value, pos);
+        for (unsigned int n = 0; n < i.value->listSize(); ++n) {
+          std::string s = state.coerceToString(posDrvName, *(*i.value->list)[n],
+                                               context, true);
           drv.args.push_back(s);
         }
       }
@@ -577,48 +577,48 @@ static void prim_derivationStrict(EvalState& state, const Pos& pos,
          the environment. */
       else {
         if (jsonObject) {
-          if (i->name == state.sStructuredAttrs) {
+          if (i.name == state.sStructuredAttrs) {
             continue;
           }
 
           auto placeholder(jsonObject->placeholder(key));
-          printValueAsJSON(state, true, *i->value, placeholder, context);
-
-          if (i->name == state.sBuilder) {
-            drv.builder = state.forceString(*i->value, context, posDrvName);
-          } else if (i->name == state.sSystem) {
-            drv.platform = state.forceStringNoCtx(*i->value, posDrvName);
-          } else if (i->name == state.sOutputHash) {
-            outputHash = state.forceStringNoCtx(*i->value, posDrvName);
-          } else if (i->name == state.sOutputHashAlgo) {
-            outputHashAlgo = state.forceStringNoCtx(*i->value, posDrvName);
-          } else if (i->name == state.sOutputHashMode) {
-            handleHashMode(state.forceStringNoCtx(*i->value, posDrvName));
-          } else if (i->name == state.sOutputs) {
+          printValueAsJSON(state, true, *i.value, placeholder, context);
+
+          if (i.name == state.sBuilder) {
+            drv.builder = state.forceString(*i.value, context, posDrvName);
+          } else if (i.name == state.sSystem) {
+            drv.platform = state.forceStringNoCtx(*i.value, posDrvName);
+          } else if (i.name == state.sOutputHash) {
+            outputHash = state.forceStringNoCtx(*i.value, posDrvName);
+          } else if (i.name == state.sOutputHashAlgo) {
+            outputHashAlgo = state.forceStringNoCtx(*i.value, posDrvName);
+          } else if (i.name == state.sOutputHashMode) {
+            handleHashMode(state.forceStringNoCtx(*i.value, posDrvName));
+          } else if (i.name == state.sOutputs) {
             /* Require ‘outputs’ to be a list of strings. */
-            state.forceList(*i->value, posDrvName);
+            state.forceList(*i.value, posDrvName);
             Strings ss;
-            for (unsigned int n = 0; n < i->value->listSize(); ++n) {
+            for (unsigned int n = 0; n < i.value->listSize(); ++n) {
               ss.emplace_back(
-                  state.forceStringNoCtx(*(*i->value->list)[n], posDrvName));
+                  state.forceStringNoCtx(*(*i.value->list)[n], posDrvName));
             }
             handleOutputs(ss);
           }
 
         } else {
-          auto s = state.coerceToString(posDrvName, *i->value, context, true);
+          auto s = state.coerceToString(posDrvName, *i.value, context, true);
           drv.env.emplace(key, s);
-          if (i->name == state.sBuilder) {
+          if (i.name == state.sBuilder) {
             drv.builder = s;
-          } else if (i->name == state.sSystem) {
+          } else if (i.name == state.sSystem) {
             drv.platform = s;
-          } else if (i->name == state.sOutputHash) {
+          } else if (i.name == state.sOutputHash) {
             outputHash = s;
-          } else if (i->name == state.sOutputHashAlgo) {
+          } else if (i.name == state.sOutputHashAlgo) {
             outputHashAlgo = s;
-          } else if (i->name == state.sOutputHashMode) {
+          } else if (i.name == state.sOutputHashMode) {
             handleHashMode(s);
-          } else if (i->name == state.sOutputs) {
+          } else if (i.name == state.sOutputs) {
             handleOutputs(absl::StrSplit(s, absl::ByAnyChar(" \t\n\r"),
                                          absl::SkipEmpty()));
           }