From 68e6e92a20b8ee01de3b89e72fc68517fea6f70c Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 22 May 2020 03:35:07 +0100 Subject: chore(3p/nix/libexpr): Delete Bindings::sort This function does nothing anymore since the attributes are always in-order. --- third_party/nix/src/libexpr/attr-set.cc | 3 --- third_party/nix/src/libexpr/attr-set.hh | 3 --- third_party/nix/src/libexpr/common-eval-args.cc | 1 - third_party/nix/src/libexpr/eval.cc | 11 +---------- third_party/nix/src/libexpr/get-drvs.cc | 1 - third_party/nix/src/libexpr/json-to-value.cc | 1 - third_party/nix/src/libexpr/primops.cc | 17 +---------------- third_party/nix/src/libexpr/primops/context.cc | 2 -- third_party/nix/src/libexpr/primops/fetchGit.cc | 4 ++-- third_party/nix/src/libexpr/primops/fetchMercurial.cc | 4 ++-- third_party/nix/src/libexpr/primops/fromTOML.cc | 2 -- 11 files changed, 6 insertions(+), 43 deletions(-) (limited to 'third_party/nix/src/libexpr') 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 @@ -53,9 +53,6 @@ class Bindings { // Merge values from other into the current attribute void merge(Bindings* other); - // ??? - [[deprecated]] void sort(); - // ??? [[deprecated]] size_t capacity(); 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()) { -- cgit 1.4.1