Merge #34866: nixos doc: efficient comparisons
This solves most of the performance regression from a7d75ab (#33898).
This commit is contained in:
commit
040bde9052
@ -85,6 +85,7 @@ rec {
|
|||||||
concatMap (opt:
|
concatMap (opt:
|
||||||
let
|
let
|
||||||
docOption = rec {
|
docOption = rec {
|
||||||
|
loc = opt.loc;
|
||||||
name = showOption opt.loc;
|
name = showOption opt.loc;
|
||||||
description = opt.description or (throw "Option `${name}' has no description.");
|
description = opt.description or (throw "Option `${name}' has no description.");
|
||||||
declarations = filter (x: x != unknownModule) opt.declarations;
|
declarations = filter (x: x != unknownModule) opt.declarations;
|
||||||
|
@ -63,18 +63,17 @@ let
|
|||||||
stripAnyPrefixes = lib.flip (lib.fold lib.removePrefix) prefixesToStrip;
|
stripAnyPrefixes = lib.flip (lib.fold lib.removePrefix) prefixesToStrip;
|
||||||
|
|
||||||
# Custom "less" that pushes up all the things ending in ".enable*"
|
# Custom "less" that pushes up all the things ending in ".enable*"
|
||||||
# and ".package"
|
# and ".package*"
|
||||||
optionListLess = a: b:
|
optionLess = a: b:
|
||||||
let
|
let
|
||||||
splt = lib.splitString ".";
|
|
||||||
ise = lib.hasPrefix "enable";
|
ise = lib.hasPrefix "enable";
|
||||||
isp = lib.hasPrefix "package";
|
isp = lib.hasPrefix "package";
|
||||||
cmp = lib.splitByAndCompare ise lib.compare
|
cmp = lib.splitByAndCompare ise lib.compare
|
||||||
(lib.splitByAndCompare isp lib.compare lib.compare);
|
(lib.splitByAndCompare isp lib.compare lib.compare);
|
||||||
in lib.compareLists cmp (splt a) (splt b) < 0;
|
in lib.compareLists cmp a.loc b.loc < 0;
|
||||||
|
|
||||||
# Customly sort option list for the man page.
|
# Customly sort option list for the man page.
|
||||||
optionsList = lib.sort (a: b: optionListLess a.name b.name) optionsListDesc;
|
optionsList = lib.sort optionLess optionsListDesc;
|
||||||
|
|
||||||
# Convert the list of options into an XML file.
|
# Convert the list of options into an XML file.
|
||||||
optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList);
|
optionsXML = builtins.toFile "options.xml" (builtins.toXML optionsList);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user