about summary refs log tree commit diff
path: root/third_party
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-22T02·35+0100
committerVincent Ambo <tazjin@google.com>2020-05-22T02·35+0100
commit68e6e92a20b8ee01de3b89e72fc68517fea6f70c (patch)
treeeb44f148e6cabe0d9281d861a379f7c19cd2783a /third_party
parent986a8f6b75ffa51682cbe730c5c2907296082cd4 (diff)
chore(3p/nix/libexpr): Delete Bindings::sort r/803
This function does nothing anymore since the attributes are always
in-order.
Diffstat (limited to 'third_party')
-rw-r--r--third_party/nix/src/libexpr/attr-set.cc3
-rw-r--r--third_party/nix/src/libexpr/attr-set.hh3
-rw-r--r--third_party/nix/src/libexpr/common-eval-args.cc1
-rw-r--r--third_party/nix/src/libexpr/eval.cc11
-rw-r--r--third_party/nix/src/libexpr/get-drvs.cc1
-rw-r--r--third_party/nix/src/libexpr/json-to-value.cc1
-rw-r--r--third_party/nix/src/libexpr/primops.cc17
-rw-r--r--third_party/nix/src/libexpr/primops/context.cc2
-rw-r--r--third_party/nix/src/libexpr/primops/fetchGit.cc4
-rw-r--r--third_party/nix/src/libexpr/primops/fetchMercurial.cc4
-rw-r--r--third_party/nix/src/libexpr/primops/fromTOML.cc2
-rw-r--r--third_party/nix/src/nix-env/nix-env.cc5
-rw-r--r--third_party/nix/src/nix-env/user-env.cc3
-rw-r--r--third_party/nix/src/nix/installables.cc3
14 files changed, 6 insertions, 54 deletions
diff --git a/third_party/nix/src/libexpr/attr-set.cc b/third_party/nix/src/libexpr/attr-set.cc
index a74292666b..eb9db3f46d 100644
--- a/third_party/nix/src/libexpr/attr-set.cc
+++ b/third_party/nix/src/libexpr/attr-set.cc
@@ -14,7 +14,6 @@ void Bindings::push_back(const Attr& attr) {
 
 size_t Bindings::size() { return attributes_.size(); }
 
-void Bindings::sort() {}
 size_t Bindings::capacity() { return 0; }
 
 bool Bindings::empty() { return attributes_.empty(); }
@@ -74,6 +73,4 @@ Value* EvalState::allocAttr(Value& vAttrs, const Symbol& name) {
   return v;
 }
 
-// void Bindings::sort() { std::sort(begin(), end()); }
-
 }  // namespace nix
diff --git a/third_party/nix/src/libexpr/attr-set.hh b/third_party/nix/src/libexpr/attr-set.hh
index 4ae908964c..8327333653 100644
--- a/third_party/nix/src/libexpr/attr-set.hh
+++ b/third_party/nix/src/libexpr/attr-set.hh
@@ -54,9 +54,6 @@ class Bindings {
   void merge(Bindings* other);
 
   // ???
-  [[deprecated]] void sort();
-
-  // ???
   [[deprecated]] size_t capacity();
 
   // oh no
diff --git a/third_party/nix/src/libexpr/common-eval-args.cc b/third_party/nix/src/libexpr/common-eval-args.cc
index 8b650690f2..1b9db51c61 100644
--- a/third_party/nix/src/libexpr/common-eval-args.cc
+++ b/third_party/nix/src/libexpr/common-eval-args.cc
@@ -44,7 +44,6 @@ Bindings* MixEvalArgs::getAutoArgs(EvalState& state) {
     }
     res->push_back(Attr(state.symbols.Create(i.first), v));
   }
-  res->sort();
   return res;
 }
 
diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc
index dbf02134a2..679d3ca996 100644
--- a/third_party/nix/src/libexpr/eval.cc
+++ b/third_party/nix/src/libexpr/eval.cc
@@ -683,7 +683,6 @@ void EvalState::mkPos(Value& v, Pos* pos) {
     mkString(*allocAttr(v, sFile), pos->file);
     mkInt(*allocAttr(v, sLine), pos->line);
     mkInt(*allocAttr(v, sColumn), pos->column);
-    v.attrs->sort();
   } else {
     mkNull(v);
   }
@@ -856,9 +855,7 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) {
        been substituted into the bodies of the other attributes.
        Hence we need __overrides.) */
     if (hasOverrides) {
-      Value* vOverrides =
-          //(*v.attrs)[overrides->second.displ].value;
-          v.attrs->find(overrides->first)->second.value;
+      Value* vOverrides = v.attrs->find(overrides->first)->second.value;
       state.forceAttrs(*vOverrides);
       Bindings* newBnds = state.allocBindings(/* capacity = */ 0);
       for (auto& i : *v.attrs) {  // TODO(tazjin): copy constructor?
@@ -868,13 +865,11 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) {
         auto j = attrs.find(i.second.name);
         if (j != attrs.end()) {
           newBnds->push_back(i.second);
-          // (*newBnds)[j->second.displ] = i;
           env2.values[j->second.displ] = i.second.value;
         } else {
           newBnds->push_back(i.second);
         }
       }
-      newBnds->sort();
       v.attrs = newBnds;
     }
   } else {
@@ -902,10 +897,8 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) {
     }
 
     i.valueExpr->setName(nameSym);
-    /* Keep sorted order so find can catch duplicates */
     v.attrs->push_back(
         Attr(nameSym, i.valueExpr->maybeThunk(state, *dynamicEnv), &i.pos));
-    v.attrs->sort();  // FIXME: inefficient
   }
 }
 
@@ -1224,8 +1217,6 @@ void EvalState::autoCallFunction(Bindings& args, Value& fun, Value& res) {
     }
   }
 
-  actualArgs->attrs->sort();
-
   callFunction(fun, *actualArgs, res, noPos);
 }
 
diff --git a/third_party/nix/src/libexpr/get-drvs.cc b/third_party/nix/src/libexpr/get-drvs.cc
index 5b33afdba9..822bff3699 100644
--- a/third_party/nix/src/libexpr/get-drvs.cc
+++ b/third_party/nix/src/libexpr/get-drvs.cc
@@ -305,7 +305,6 @@ void DrvInfo::setMeta(const std::string& name, Value* v) {
   if (v != nullptr) {
     meta->push_back(Attr(sym, v));
   }
-  meta->sort();
 }
 
 /* Cache for already considered attrsets. */
diff --git a/third_party/nix/src/libexpr/json-to-value.cc b/third_party/nix/src/libexpr/json-to-value.cc
index 17603c59ea..d46e6f268e 100644
--- a/third_party/nix/src/libexpr/json-to-value.cc
+++ b/third_party/nix/src/libexpr/json-to-value.cc
@@ -119,7 +119,6 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) {
     for (auto& i : attrs) {
       v.attrs->push_back(Attr(i.first, i.second));
     }
-    v.attrs->sort();
     s++;
   }
 
diff --git a/third_party/nix/src/libexpr/primops.cc b/third_party/nix/src/libexpr/primops.cc
index 608d6d0413..713c31e4fa 100644
--- a/third_party/nix/src/libexpr/primops.cc
+++ b/third_party/nix/src/libexpr/primops.cc
@@ -128,7 +128,6 @@ static void prim_scopedImport(EvalState& state, const Pos& pos, Value** args,
       outputsVal->listElems()[outputs_index] = state.allocValue();
       mkString(*(outputsVal->listElems()[outputs_index++]), o.first);
     }
-    w.attrs->sort();
     Value fun;
     state.evalFile(
         settings.nixDataDir + "/nix/corepkgs/imported-drv-to-derivation.nix",
@@ -498,7 +497,6 @@ static void prim_tryEval(EvalState& state, const Pos& pos, Value** args,
     mkBool(*state.allocAttr(v, state.sValue), false);
     mkBool(*state.allocAttr(v, state.symbols.Create("success")), false);
   }
-  v.attrs->sort();
 }
 
 /* Return an environment variable.  Use with care. */
@@ -850,7 +848,6 @@ static void prim_derivationStrict(EvalState& state, const Pos& pos,
     mkString(*state.allocAttr(v, state.symbols.Create(i.first)), i.second.path,
              {"!" + i.first + "!" + drvPath});
   }
-  v.attrs->sort();
 }
 
 /* Return a placeholder string for the specified output that will be
@@ -1064,8 +1061,6 @@ static void prim_readDir(EvalState& state, const Pos& pos, Value** args,
                              ? "directory"
                              : ent.type == DT_LNK ? "symlink" : "unknown");
   }
-
-  v.attrs->sort();
 }
 
 /*************************************************************
@@ -1412,8 +1407,6 @@ static void prim_listToAttrs(EvalState& state, const Pos& pos, Value** args,
       seen.insert(sym);
     }
   }
-
-  v.attrs->sort();
 }
 
 /* Return the right-biased intersection of two sets as1 and as2,
@@ -1493,9 +1486,9 @@ static void prim_functionArgs(EvalState& state, const Pos& pos, Value** args,
   state.mkAttrs(v, args[0]->lambda.fun->formals->formals.size());
   for (auto& i : args[0]->lambda.fun->formals->formals) {
     // !!! should optimise booleans (allocate only once)
+    // TODO(tazjin): figure out what the above comment means
     mkBool(*state.allocAttr(v, i.name), i.def != nullptr);
   }
-  v.attrs->sort();
 }
 
 /* Apply a function to every element of an attribute set. */
@@ -1774,8 +1767,6 @@ static void prim_partition(EvalState& state, const Pos& pos, Value** args,
   if (wsize != 0u) {
     memcpy(vWrong->listElems(), wrong.data(), sizeof(Value*) * wsize);
   }
-
-  v.attrs->sort();
 }
 
 /* concatMap = f: list: concatLists (map f list); */
@@ -2153,7 +2144,6 @@ static void prim_parseDrvName(EvalState& state, const Pos& pos, Value** args,
   mkString(*state.allocAttr(v, state.sName), parsed.name);
   mkString(*state.allocAttr(v, state.symbols.Create("version")),
            parsed.version);
-  v.attrs->sort();
 }
 
 static void prim_compareVersions(EvalState& state, const Pos& pos, Value** args,
@@ -2453,7 +2443,6 @@ void EvalState::createBaseEnv() {
     mkAttrs(*v2, 2);
     mkString(*allocAttr(*v2, symbols.Create("path")), i.second);
     mkString(*allocAttr(*v2, symbols.Create("prefix")), i.first);
-    v2->attrs->sort();
   }
   addConstant("__nixPath", v);
 
@@ -2462,10 +2451,6 @@ void EvalState::createBaseEnv() {
       addPrimOp(std::get<0>(primOp), std::get<1>(primOp), std::get<2>(primOp));
     }
   }
-
-  /* Now that we've added all primops, sort the `builtins' set,
-     because attribute lookups expect it to be sorted. */
-  baseEnv.values[0]->attrs->sort();
 }
 
 }  // namespace nix
diff --git a/third_party/nix/src/libexpr/primops/context.cc b/third_party/nix/src/libexpr/primops/context.cc
index 1661ffbe2e..2ae8ba8aa9 100644
--- a/third_party/nix/src/libexpr/primops/context.cc
+++ b/third_party/nix/src/libexpr/primops/context.cc
@@ -126,9 +126,7 @@ static void prim_getContext(EvalState& state, const Pos& pos, Value** args,
         mkString(*(outputsVal.listElems()[i++] = state.allocValue()), output);
       }
     }
-    infoVal.attrs->sort();
   }
-  v.attrs->sort();
 }
 
 static RegisterPrimOp r4("__getContext", 1, prim_getContext);
diff --git a/third_party/nix/src/libexpr/primops/fetchGit.cc b/third_party/nix/src/libexpr/primops/fetchGit.cc
index cb4c008cdd..67641258d5 100644
--- a/third_party/nix/src/libexpr/primops/fetchGit.cc
+++ b/third_party/nix/src/libexpr/primops/fetchGit.cc
@@ -252,10 +252,10 @@ static void prim_fetchGit(EvalState& state, const Pos& pos, Value** args,
            gitInfo.shortRev);
   mkInt(*state.allocAttr(v, state.symbols.Create("revCount")),
         gitInfo.revCount);
-  v.attrs->sort();
 
-  if (state.allowedPaths)
+  if (state.allowedPaths) {
     state.allowedPaths->insert(state.store->toRealPath(gitInfo.storePath));
+  }
 }
 
 static RegisterPrimOp r("fetchGit", 1, prim_fetchGit);
diff --git a/third_party/nix/src/libexpr/primops/fetchMercurial.cc b/third_party/nix/src/libexpr/primops/fetchMercurial.cc
index 1e7064f97d..9223f1c3ca 100644
--- a/third_party/nix/src/libexpr/primops/fetchMercurial.cc
+++ b/third_party/nix/src/libexpr/primops/fetchMercurial.cc
@@ -226,10 +226,10 @@ static void prim_fetchMercurial(EvalState& state, const Pos& pos, Value** args,
   mkString(*state.allocAttr(v, state.symbols.Create("shortRev")),
            std::string(hgInfo.rev, 0, 12));
   mkInt(*state.allocAttr(v, state.symbols.Create("revCount")), hgInfo.revCount);
-  v.attrs->sort();
 
-  if (state.allowedPaths)
+  if (state.allowedPaths) {
     state.allowedPaths->insert(state.store->toRealPath(hgInfo.storePath));
+  }
 }
 
 static RegisterPrimOp r("fetchMercurial", 1, prim_fetchMercurial);
diff --git a/third_party/nix/src/libexpr/primops/fromTOML.cc b/third_party/nix/src/libexpr/primops/fromTOML.cc
index 320b6120e7..cc7b3cfcc3 100644
--- a/third_party/nix/src/libexpr/primops/fromTOML.cc
+++ b/third_party/nix/src/libexpr/primops/fromTOML.cc
@@ -35,8 +35,6 @@ static void prim_fromTOML(EvalState& state, const Pos& pos, Value** args,
         } else
           visit(v2, i.second);
       }
-
-      v.attrs->sort();
     }
 
     else if (auto t2 = t->as_array()) {
diff --git a/third_party/nix/src/nix-env/nix-env.cc b/third_party/nix/src/nix-env/nix-env.cc
index a645fa3148..e5b7697924 100644
--- a/third_party/nix/src/nix-env/nix-env.cc
+++ b/third_party/nix/src/nix-env/nix-env.cc
@@ -128,10 +128,6 @@ static void getAllExprs(EvalState& state, const Path& path, StringSet& attrs,
       Value& vFun = state.getBuiltin("import");
       Value& vArg(*state.allocValue());
       mkString(vArg, path2);
-      if (v.attrs->size() == v.attrs->capacity()) {
-        throw Error(format("too many Nix expressions in directory '%1%'") %
-                    path);
-      }
       mkApp(*state.allocAttr(v, state.symbols.Create(attrName)), vFun, vArg);
     } else if (S_ISDIR(st.st_mode)) {
       /* `path2' is a directory (with no default.nix in it);
@@ -163,7 +159,6 @@ static void loadSourceExpr(EvalState& state, const Path& path, Value& v) {
                  0);
     StringSet attrs;
     getAllExprs(state, path, attrs, v);
-    v.attrs->sort();
   }
 
   else {
diff --git a/third_party/nix/src/nix-env/user-env.cc b/third_party/nix/src/nix-env/user-env.cc
index 21e7d42e88..1535ca0a5c 100644
--- a/third_party/nix/src/nix-env/user-env.cc
+++ b/third_party/nix/src/nix-env/user-env.cc
@@ -96,8 +96,6 @@ bool createUserEnv(EvalState& state, DrvInfos& elems, const Path& profile,
       }
       vMeta.attrs->push_back(Attr(state.symbols.Create(j), v));
     }
-    vMeta.attrs->sort();
-    v.attrs->sort();
 
     if (!drvPath.empty()) {
       references.insert(drvPath);
@@ -122,7 +120,6 @@ bool createUserEnv(EvalState& state, DrvInfos& elems, const Path& profile,
   mkString(*state.allocAttr(args, state.symbols.Create("manifest")),
            manifestFile, {manifestFile});
   args.attrs->push_back(Attr(state.symbols.Create("derivations"), &manifest));
-  args.attrs->sort();
   mkApp(topLevel, envBuilder, args);
 
   /* Evaluate it. */
diff --git a/third_party/nix/src/nix/installables.cc b/third_party/nix/src/nix/installables.cc
index 59dfc1b1ac..38a3f0c8ec 100644
--- a/third_party/nix/src/nix/installables.cc
+++ b/third_party/nix/src/nix/installables.cc
@@ -33,7 +33,6 @@ Value* SourceExprCommand::getSourceExpr(EvalState& state) {
 
   if (!file.empty()) {
     state.evalFile(lookupFileArg(state, file), *vSourceExpr);
-
   } else {
     /* Construct the installation source from $NIX_PATH. */
 
@@ -73,8 +72,6 @@ Value* SourceExprCommand::getSourceExpr(EvalState& state) {
         addEntry(i.first);
       }
     }
-
-    vSourceExpr->attrs->sort();
   }
 
   return vSourceExpr;