chore(3p/nix/libexpr): Delete Bindings::sort
This function does nothing anymore since the attributes are always in-order.
This commit is contained in:
parent
986a8f6b75
commit
68e6e92a20
14 changed files with 6 additions and 54 deletions
3
third_party/nix/src/libexpr/attr-set.cc
vendored
3
third_party/nix/src/libexpr/attr-set.cc
vendored
|
@ -14,7 +14,6 @@ void Bindings::push_back(const Attr& attr) {
|
||||||
|
|
||||||
size_t Bindings::size() { return attributes_.size(); }
|
size_t Bindings::size() { return attributes_.size(); }
|
||||||
|
|
||||||
void Bindings::sort() {}
|
|
||||||
size_t Bindings::capacity() { return 0; }
|
size_t Bindings::capacity() { return 0; }
|
||||||
|
|
||||||
bool Bindings::empty() { return attributes_.empty(); }
|
bool Bindings::empty() { return attributes_.empty(); }
|
||||||
|
@ -74,6 +73,4 @@ Value* EvalState::allocAttr(Value& vAttrs, const Symbol& name) {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void Bindings::sort() { std::sort(begin(), end()); }
|
|
||||||
|
|
||||||
} // namespace nix
|
} // namespace nix
|
||||||
|
|
3
third_party/nix/src/libexpr/attr-set.hh
vendored
3
third_party/nix/src/libexpr/attr-set.hh
vendored
|
@ -53,9 +53,6 @@ class Bindings {
|
||||||
// Merge values from other into the current attribute
|
// Merge values from other into the current attribute
|
||||||
void merge(Bindings* other);
|
void merge(Bindings* other);
|
||||||
|
|
||||||
// ???
|
|
||||||
[[deprecated]] void sort();
|
|
||||||
|
|
||||||
// ???
|
// ???
|
||||||
[[deprecated]] size_t capacity();
|
[[deprecated]] size_t capacity();
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,6 @@ Bindings* MixEvalArgs::getAutoArgs(EvalState& state) {
|
||||||
}
|
}
|
||||||
res->push_back(Attr(state.symbols.Create(i.first), v));
|
res->push_back(Attr(state.symbols.Create(i.first), v));
|
||||||
}
|
}
|
||||||
res->sort();
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
11
third_party/nix/src/libexpr/eval.cc
vendored
11
third_party/nix/src/libexpr/eval.cc
vendored
|
@ -683,7 +683,6 @@ void EvalState::mkPos(Value& v, Pos* pos) {
|
||||||
mkString(*allocAttr(v, sFile), pos->file);
|
mkString(*allocAttr(v, sFile), pos->file);
|
||||||
mkInt(*allocAttr(v, sLine), pos->line);
|
mkInt(*allocAttr(v, sLine), pos->line);
|
||||||
mkInt(*allocAttr(v, sColumn), pos->column);
|
mkInt(*allocAttr(v, sColumn), pos->column);
|
||||||
v.attrs->sort();
|
|
||||||
} else {
|
} else {
|
||||||
mkNull(v);
|
mkNull(v);
|
||||||
}
|
}
|
||||||
|
@ -856,9 +855,7 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) {
|
||||||
been substituted into the bodies of the other attributes.
|
been substituted into the bodies of the other attributes.
|
||||||
Hence we need __overrides.) */
|
Hence we need __overrides.) */
|
||||||
if (hasOverrides) {
|
if (hasOverrides) {
|
||||||
Value* vOverrides =
|
Value* vOverrides = v.attrs->find(overrides->first)->second.value;
|
||||||
//(*v.attrs)[overrides->second.displ].value;
|
|
||||||
v.attrs->find(overrides->first)->second.value;
|
|
||||||
state.forceAttrs(*vOverrides);
|
state.forceAttrs(*vOverrides);
|
||||||
Bindings* newBnds = state.allocBindings(/* capacity = */ 0);
|
Bindings* newBnds = state.allocBindings(/* capacity = */ 0);
|
||||||
for (auto& i : *v.attrs) { // TODO(tazjin): copy constructor?
|
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);
|
auto j = attrs.find(i.second.name);
|
||||||
if (j != attrs.end()) {
|
if (j != attrs.end()) {
|
||||||
newBnds->push_back(i.second);
|
newBnds->push_back(i.second);
|
||||||
// (*newBnds)[j->second.displ] = i;
|
|
||||||
env2.values[j->second.displ] = i.second.value;
|
env2.values[j->second.displ] = i.second.value;
|
||||||
} else {
|
} else {
|
||||||
newBnds->push_back(i.second);
|
newBnds->push_back(i.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newBnds->sort();
|
|
||||||
v.attrs = newBnds;
|
v.attrs = newBnds;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -902,10 +897,8 @@ void ExprAttrs::eval(EvalState& state, Env& env, Value& v) {
|
||||||
}
|
}
|
||||||
|
|
||||||
i.valueExpr->setName(nameSym);
|
i.valueExpr->setName(nameSym);
|
||||||
/* Keep sorted order so find can catch duplicates */
|
|
||||||
v.attrs->push_back(
|
v.attrs->push_back(
|
||||||
Attr(nameSym, i.valueExpr->maybeThunk(state, *dynamicEnv), &i.pos));
|
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);
|
callFunction(fun, *actualArgs, res, noPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
third_party/nix/src/libexpr/get-drvs.cc
vendored
1
third_party/nix/src/libexpr/get-drvs.cc
vendored
|
@ -305,7 +305,6 @@ void DrvInfo::setMeta(const std::string& name, Value* v) {
|
||||||
if (v != nullptr) {
|
if (v != nullptr) {
|
||||||
meta->push_back(Attr(sym, v));
|
meta->push_back(Attr(sym, v));
|
||||||
}
|
}
|
||||||
meta->sort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Cache for already considered attrsets. */
|
/* Cache for already considered attrsets. */
|
||||||
|
|
1
third_party/nix/src/libexpr/json-to-value.cc
vendored
1
third_party/nix/src/libexpr/json-to-value.cc
vendored
|
@ -119,7 +119,6 @@ static void parseJSON(EvalState& state, const char*& s, Value& v) {
|
||||||
for (auto& i : attrs) {
|
for (auto& i : attrs) {
|
||||||
v.attrs->push_back(Attr(i.first, i.second));
|
v.attrs->push_back(Attr(i.first, i.second));
|
||||||
}
|
}
|
||||||
v.attrs->sort();
|
|
||||||
s++;
|
s++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
third_party/nix/src/libexpr/primops.cc
vendored
17
third_party/nix/src/libexpr/primops.cc
vendored
|
@ -128,7 +128,6 @@ static void prim_scopedImport(EvalState& state, const Pos& pos, Value** args,
|
||||||
outputsVal->listElems()[outputs_index] = state.allocValue();
|
outputsVal->listElems()[outputs_index] = state.allocValue();
|
||||||
mkString(*(outputsVal->listElems()[outputs_index++]), o.first);
|
mkString(*(outputsVal->listElems()[outputs_index++]), o.first);
|
||||||
}
|
}
|
||||||
w.attrs->sort();
|
|
||||||
Value fun;
|
Value fun;
|
||||||
state.evalFile(
|
state.evalFile(
|
||||||
settings.nixDataDir + "/nix/corepkgs/imported-drv-to-derivation.nix",
|
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.sValue), false);
|
||||||
mkBool(*state.allocAttr(v, state.symbols.Create("success")), false);
|
mkBool(*state.allocAttr(v, state.symbols.Create("success")), false);
|
||||||
}
|
}
|
||||||
v.attrs->sort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return an environment variable. Use with care. */
|
/* 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,
|
mkString(*state.allocAttr(v, state.symbols.Create(i.first)), i.second.path,
|
||||||
{"!" + i.first + "!" + drvPath});
|
{"!" + i.first + "!" + drvPath});
|
||||||
}
|
}
|
||||||
v.attrs->sort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a placeholder string for the specified output that will be
|
/* 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"
|
? "directory"
|
||||||
: ent.type == DT_LNK ? "symlink" : "unknown");
|
: 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);
|
seen.insert(sym);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
v.attrs->sort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the right-biased intersection of two sets as1 and as2,
|
/* 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());
|
state.mkAttrs(v, args[0]->lambda.fun->formals->formals.size());
|
||||||
for (auto& i : args[0]->lambda.fun->formals->formals) {
|
for (auto& i : args[0]->lambda.fun->formals->formals) {
|
||||||
// !!! should optimise booleans (allocate only once)
|
// !!! should optimise booleans (allocate only once)
|
||||||
|
// TODO(tazjin): figure out what the above comment means
|
||||||
mkBool(*state.allocAttr(v, i.name), i.def != nullptr);
|
mkBool(*state.allocAttr(v, i.name), i.def != nullptr);
|
||||||
}
|
}
|
||||||
v.attrs->sort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply a function to every element of an attribute set. */
|
/* 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) {
|
if (wsize != 0u) {
|
||||||
memcpy(vWrong->listElems(), wrong.data(), sizeof(Value*) * wsize);
|
memcpy(vWrong->listElems(), wrong.data(), sizeof(Value*) * wsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
v.attrs->sort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* concatMap = f: list: concatLists (map f list); */
|
/* 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.sName), parsed.name);
|
||||||
mkString(*state.allocAttr(v, state.symbols.Create("version")),
|
mkString(*state.allocAttr(v, state.symbols.Create("version")),
|
||||||
parsed.version);
|
parsed.version);
|
||||||
v.attrs->sort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prim_compareVersions(EvalState& state, const Pos& pos, Value** args,
|
static void prim_compareVersions(EvalState& state, const Pos& pos, Value** args,
|
||||||
|
@ -2453,7 +2443,6 @@ void EvalState::createBaseEnv() {
|
||||||
mkAttrs(*v2, 2);
|
mkAttrs(*v2, 2);
|
||||||
mkString(*allocAttr(*v2, symbols.Create("path")), i.second);
|
mkString(*allocAttr(*v2, symbols.Create("path")), i.second);
|
||||||
mkString(*allocAttr(*v2, symbols.Create("prefix")), i.first);
|
mkString(*allocAttr(*v2, symbols.Create("prefix")), i.first);
|
||||||
v2->attrs->sort();
|
|
||||||
}
|
}
|
||||||
addConstant("__nixPath", v);
|
addConstant("__nixPath", v);
|
||||||
|
|
||||||
|
@ -2462,10 +2451,6 @@ void EvalState::createBaseEnv() {
|
||||||
addPrimOp(std::get<0>(primOp), std::get<1>(primOp), std::get<2>(primOp));
|
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
|
} // namespace nix
|
||||||
|
|
|
@ -126,9 +126,7 @@ static void prim_getContext(EvalState& state, const Pos& pos, Value** args,
|
||||||
mkString(*(outputsVal.listElems()[i++] = state.allocValue()), output);
|
mkString(*(outputsVal.listElems()[i++] = state.allocValue()), output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
infoVal.attrs->sort();
|
|
||||||
}
|
}
|
||||||
v.attrs->sort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp r4("__getContext", 1, prim_getContext);
|
static RegisterPrimOp r4("__getContext", 1, prim_getContext);
|
||||||
|
|
|
@ -252,10 +252,10 @@ static void prim_fetchGit(EvalState& state, const Pos& pos, Value** args,
|
||||||
gitInfo.shortRev);
|
gitInfo.shortRev);
|
||||||
mkInt(*state.allocAttr(v, state.symbols.Create("revCount")),
|
mkInt(*state.allocAttr(v, state.symbols.Create("revCount")),
|
||||||
gitInfo.revCount);
|
gitInfo.revCount);
|
||||||
v.attrs->sort();
|
|
||||||
|
|
||||||
if (state.allowedPaths)
|
if (state.allowedPaths) {
|
||||||
state.allowedPaths->insert(state.store->toRealPath(gitInfo.storePath));
|
state.allowedPaths->insert(state.store->toRealPath(gitInfo.storePath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp r("fetchGit", 1, prim_fetchGit);
|
static RegisterPrimOp r("fetchGit", 1, prim_fetchGit);
|
||||||
|
|
|
@ -226,10 +226,10 @@ static void prim_fetchMercurial(EvalState& state, const Pos& pos, Value** args,
|
||||||
mkString(*state.allocAttr(v, state.symbols.Create("shortRev")),
|
mkString(*state.allocAttr(v, state.symbols.Create("shortRev")),
|
||||||
std::string(hgInfo.rev, 0, 12));
|
std::string(hgInfo.rev, 0, 12));
|
||||||
mkInt(*state.allocAttr(v, state.symbols.Create("revCount")), hgInfo.revCount);
|
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));
|
state.allowedPaths->insert(state.store->toRealPath(hgInfo.storePath));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static RegisterPrimOp r("fetchMercurial", 1, prim_fetchMercurial);
|
static RegisterPrimOp r("fetchMercurial", 1, prim_fetchMercurial);
|
||||||
|
|
|
@ -35,8 +35,6 @@ static void prim_fromTOML(EvalState& state, const Pos& pos, Value** args,
|
||||||
} else
|
} else
|
||||||
visit(v2, i.second);
|
visit(v2, i.second);
|
||||||
}
|
}
|
||||||
|
|
||||||
v.attrs->sort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (auto t2 = t->as_array()) {
|
else if (auto t2 = t->as_array()) {
|
||||||
|
|
5
third_party/nix/src/nix-env/nix-env.cc
vendored
5
third_party/nix/src/nix-env/nix-env.cc
vendored
|
@ -128,10 +128,6 @@ static void getAllExprs(EvalState& state, const Path& path, StringSet& attrs,
|
||||||
Value& vFun = state.getBuiltin("import");
|
Value& vFun = state.getBuiltin("import");
|
||||||
Value& vArg(*state.allocValue());
|
Value& vArg(*state.allocValue());
|
||||||
mkString(vArg, path2);
|
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);
|
mkApp(*state.allocAttr(v, state.symbols.Create(attrName)), vFun, vArg);
|
||||||
} else if (S_ISDIR(st.st_mode)) {
|
} else if (S_ISDIR(st.st_mode)) {
|
||||||
/* `path2' is a directory (with no default.nix in it);
|
/* `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);
|
0);
|
||||||
StringSet attrs;
|
StringSet attrs;
|
||||||
getAllExprs(state, path, attrs, v);
|
getAllExprs(state, path, attrs, v);
|
||||||
v.attrs->sort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
3
third_party/nix/src/nix-env/user-env.cc
vendored
3
third_party/nix/src/nix-env/user-env.cc
vendored
|
@ -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->push_back(Attr(state.symbols.Create(j), v));
|
||||||
}
|
}
|
||||||
vMeta.attrs->sort();
|
|
||||||
v.attrs->sort();
|
|
||||||
|
|
||||||
if (!drvPath.empty()) {
|
if (!drvPath.empty()) {
|
||||||
references.insert(drvPath);
|
references.insert(drvPath);
|
||||||
|
@ -122,7 +120,6 @@ bool createUserEnv(EvalState& state, DrvInfos& elems, const Path& profile,
|
||||||
mkString(*state.allocAttr(args, state.symbols.Create("manifest")),
|
mkString(*state.allocAttr(args, state.symbols.Create("manifest")),
|
||||||
manifestFile, {manifestFile});
|
manifestFile, {manifestFile});
|
||||||
args.attrs->push_back(Attr(state.symbols.Create("derivations"), &manifest));
|
args.attrs->push_back(Attr(state.symbols.Create("derivations"), &manifest));
|
||||||
args.attrs->sort();
|
|
||||||
mkApp(topLevel, envBuilder, args);
|
mkApp(topLevel, envBuilder, args);
|
||||||
|
|
||||||
/* Evaluate it. */
|
/* Evaluate it. */
|
||||||
|
|
3
third_party/nix/src/nix/installables.cc
vendored
3
third_party/nix/src/nix/installables.cc
vendored
|
@ -33,7 +33,6 @@ Value* SourceExprCommand::getSourceExpr(EvalState& state) {
|
||||||
|
|
||||||
if (!file.empty()) {
|
if (!file.empty()) {
|
||||||
state.evalFile(lookupFileArg(state, file), *vSourceExpr);
|
state.evalFile(lookupFileArg(state, file), *vSourceExpr);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Construct the installation source from $NIX_PATH. */
|
/* Construct the installation source from $NIX_PATH. */
|
||||||
|
|
||||||
|
@ -73,8 +72,6 @@ Value* SourceExprCommand::getSourceExpr(EvalState& state) {
|
||||||
addEntry(i.first);
|
addEntry(i.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vSourceExpr->attrs->sort();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return vSourceExpr;
|
return vSourceExpr;
|
||||||
|
|
Loading…
Add table
Reference in a new issue