git.iko.soy/typeable/nixpkgs
on master help sign in
Merge #34866: nixos doc: efficient comparisons

This solves most of the performance regression from a7d75ab (#33898).

commit040bde90521c9956e8970b35305a337732cf0ade authorVladimír Čunát <vcunat@gmail.com> dateMon 12 Feb 2018, 08:31 (9 years ago) parent53e790eb468f98
2 files changed+5−5
lib/options.nix+1 nixos/doc/manual/default.nix+4−5
lib/options.nix+1
@@ -85,6 +85,7 @@ rec {
8585 concatMap (opt:
8686 let
8787 docOption = rec {
88+ loc = opt.loc;
8889 name = showOption opt.loc;
8990 description = opt.description or (throw "Option `${name}' has no description.");
9091 declarations = filter (x: x != unknownModule) opt.declarations;
nixos/doc/manual/default.nix+4−5
@@ -63,18 +63,17 @@ let
6363 stripAnyPrefixes = lib.flip (lib.fold lib.removePrefix) prefixesToStrip;
6464
6565 # Custom "less" that pushes up all the things ending in ".enable*"
66− # and ".package"
67− optionListLess = a: b:
66+ # and ".package*"
67+ optionLess = a: b:
6868 let
69− splt = lib.splitString ".";
7069 ise = lib.hasPrefix "enable";
7170 isp = lib.hasPrefix "package";
7271 cmp = lib.splitByAndCompare ise lib.compare
7372 (lib.splitByAndCompare isp lib.compare lib.compare);
74− in lib.compareLists cmp (splt a) (splt b) < 0;
73+ in lib.compareLists cmp a.loc b.loc < 0;
7574
7675 # Customly sort option list for the man page.
77− optionsList = lib.sort (a: b: optionListLess a.name b.name) optionsListDesc;
76+ optionsList = lib.sort optionLess optionsListDesc;
7877
7978 # Convert the list of options into an XML file.
8079 optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList);