From e1ecc2b6c1fe10acf2a1f63f027f002ff4b9ff7c Mon Sep 17 00:00:00 2001 From: Chuck Date: Fri, 6 Sep 2019 09:58:34 -0700 Subject: [PATCH] Remove list sorting --- .../tools/nixos-option/nixos-option.cc | 37 +------------------ 1 file changed, 1 insertion(+), 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 // for nix/globals.hh's reference to SYSTEM -#include // for sort #include // for function #include // for operator<<, basic_ostream, ostrin... #include // for next @@ -276,7 +275,7 @@ Value parseAndEval(EvalState * state, std::string const & expression, std::strin void printValue(Context * ctx, Out & out, std::variant 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 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());