diff options
author | Chuck <chuck@intelligence.org> | 2019-09-06 09:58:34 -0700 |
---|---|---|
committer | Linus Heckemann <git@sphalerite.org> | 2019-11-04 15:11:45 +0100 |
commit | e1ecc2b6c1fe10acf2a1f63f027f002ff4b9ff7c (patch) | |
tree | bf883b0e739c036f7c07e0c245aa7a1a67eebe37 | |
parent | 36c00c108076915b0074fefc8ae5bb8baba476fa (diff) | |
download | nixlib-e1ecc2b6c1fe10acf2a1f63f027f002ff4b9ff7c.tar nixlib-e1ecc2b6c1fe10acf2a1f63f027f002ff4b9ff7c.tar.gz nixlib-e1ecc2b6c1fe10acf2a1f63f027f002ff4b9ff7c.tar.bz2 nixlib-e1ecc2b6c1fe10acf2a1f63f027f002ff4b9ff7c.tar.lz nixlib-e1ecc2b6c1fe10acf2a1f63f027f002ff4b9ff7c.tar.xz nixlib-e1ecc2b6c1fe10acf2a1f63f027f002ff4b9ff7c.tar.zst nixlib-e1ecc2b6c1fe10acf2a1f63f027f002ff4b9ff7c.zip |
Remove list sorting
-rw-r--r-- | nixos/modules/installer/tools/nixos-option/nixos-option.cc | 37 |
1 files changed, 1 insertions, 36 deletions
diff --git a/nixos/modules/installer/tools/nixos-option/nixos-option.cc b/nixos/modules/installer/tools/nixos-option/nixos-option.cc index d72a2ae3f8db..01eb0d5ddd18 100644 --- a/nixos/modules/installer/tools/nixos-option/nixos-option.cc +++ b/nixos/modules/installer/tools/nixos-option/nixos-option.cc @@ -1,6 +1,5 @@ #include <nix/config.h> // for nix/globals.hh's reference to SYSTEM -#include <algorithm> // for sort #include <functional> // for function #include <iostream> // for operator<<, basic_ostream, ostrin... #include <iterator> // for next @@ -276,7 +275,7 @@ Value parseAndEval(EvalState * state, std::string const & expression, std::strin void printValue(Context * ctx, Out & out, std::variant<Value, Error> maybe_value, std::string const & path); -void printUnsortedList(Context * ctx, Out & out, Value & v) +void printList(Context * ctx, Out & out, Value & v) { Out list_out(out, "[", "]", v.listSize()); for (unsigned int n = 0; n < v.listSize(); ++n) { @@ -285,40 +284,6 @@ void printUnsortedList(Context * ctx, Out & out, Value & v) } } -void printSortedList(Context * ctx, Out & out, Value & v) -{ - std::vector<std::string> results; - for (unsigned int n = 0; n < v.listSize(); ++n) { - std::ostringstream buf; - Out buf_out(buf); - printValue(ctx, buf_out, *v.listElems()[n], ""); - results.push_back(buf.str()); - } - std::sort(results.begin(), results.end()); - Out list_out(out, "[", "]", v.listSize()); - for (auto const & v : results) { - list_out << v << Out::sep; - } -} - -bool shouldSort(Context * ctx, Value & v) -{ - // Some lists should clearly be printed in sorted order, like - // environment.systemPackages. Some clearly should not, like - // services.xserver.multitouch.buttonsMap. As a conservative heuristic, sort - // lists of derivations. - return v.listSize() > 0 && ctx->state->isDerivation(*v.listElems()[0]); -} - -void printList(Context * ctx, Out & out, Value & v) -{ - if (shouldSort(ctx, v)) { - printSortedList(ctx, out, v); - } else { - printUnsortedList(ctx, out, v); - } -} - void printAttrs(Context * ctx, Out & out, Value & v, std::string const & path) { Out attrs_out(out, "{", "}", v.attrs->size()); |