diff options
-rw-r--r-- | third_party/nix/src/libexpr/attr-set.cc | 2 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/attr-set.hh | 8 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/eval.cc | 2 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/get-drvs.cc | 2 | ||||
-rw-r--r-- | third_party/nix/src/libexpr/primops.cc | 2 |
5 files changed, 10 insertions, 6 deletions
diff --git a/third_party/nix/src/libexpr/attr-set.cc b/third_party/nix/src/libexpr/attr-set.cc index f1f40454c3f8..900ae7a86e91 100644 --- a/third_party/nix/src/libexpr/attr-set.cc +++ b/third_party/nix/src/libexpr/attr-set.cc @@ -37,7 +37,7 @@ size_t Bindings::size() const { return attributes_.size(); } bool Bindings::empty() { return attributes_.empty(); } -std::vector<const Attr*> Bindings::lexicographicOrder() { +std::vector<const Attr*> Bindings::SortedByKeys() { std::vector<const Attr*> res; res.reserve(attributes_.size()); diff --git a/third_party/nix/src/libexpr/attr-set.hh b/third_party/nix/src/libexpr/attr-set.hh index 683b3e4bd75b..b918bf30ffd2 100644 --- a/third_party/nix/src/libexpr/attr-set.hh +++ b/third_party/nix/src/libexpr/attr-set.hh @@ -55,8 +55,12 @@ class Bindings { iterator begin(); iterator end(); - // TODO: can callers just iterate? - [[deprecated]] std::vector<const Attr*> lexicographicOrder(); + // Returns the elements of the attribute set as a vector, sorted + // lexicographically by keys. + // + // This is used primarily for builtins that have guaranteed + // ordering, such as `attrNames` or `attrValues`. + std::vector<const Attr*> SortedByKeys(); // oh no friend class EvalState; diff --git a/third_party/nix/src/libexpr/eval.cc b/third_party/nix/src/libexpr/eval.cc index f35f56c83c7d..704a05b197ba 100644 --- a/third_party/nix/src/libexpr/eval.cc +++ b/third_party/nix/src/libexpr/eval.cc @@ -89,7 +89,7 @@ static void printValue(std::ostream& str, std::set<const Value*>& active, break; case tAttrs: { str << "{ "; - for (auto& i : v.attrs->lexicographicOrder()) { + for (auto& i : v.attrs->SortedByKeys()) { str << i->name << " = "; printValue(str, active, *i->value); str << "; "; diff --git a/third_party/nix/src/libexpr/get-drvs.cc b/third_party/nix/src/libexpr/get-drvs.cc index 1d8fe1efa073..02ddae1f886c 100644 --- a/third_party/nix/src/libexpr/get-drvs.cc +++ b/third_party/nix/src/libexpr/get-drvs.cc @@ -387,7 +387,7 @@ static void getDerivations(EvalState& state, Value& vIn, there are names clashes between derivations, the derivation bound to the attribute with the "lower" name should take precedence). */ - for (auto& i : v.attrs->lexicographicOrder()) { + for (auto& i : v.attrs->SortedByKeys()) { DLOG(INFO) << "evaluating attribute '" << i->name << "'"; if (!std::regex_match(std::string(i->name), attrRegex)) { continue; diff --git a/third_party/nix/src/libexpr/primops.cc b/third_party/nix/src/libexpr/primops.cc index 9cda2a1472c9..fcd69144240a 100644 --- a/third_party/nix/src/libexpr/primops.cc +++ b/third_party/nix/src/libexpr/primops.cc @@ -561,7 +561,7 @@ static void prim_derivationStrict(EvalState& state, const Pos& pos, StringSet outputs; outputs.insert("out"); - for (auto& i : args[0]->attrs->lexicographicOrder()) { + for (auto& i : args[0]->attrs->SortedByKeys()) { if (i->name == state.sIgnoreNulls) { continue; } |