From f14dab05d635711daef90639f84ef3170abb216c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 23 Jul 2015 16:32:52 +0200 Subject: [PATCH] optionAttrSetToDocList: O(n^2) -> O(n) This shaves about 10% off memory consumption of NixOS evaluation. --- lib/options.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/options.nix b/lib/options.nix index bfc5b5fa2ae8..bb72ad6d125c 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -83,7 +83,7 @@ rec { optionAttrSetToDocList = optionAttrSetToDocList' []; optionAttrSetToDocList' = prefix: options: - fold (opt: rest: + concatMap (opt: let docOption = rec { name = showOption opt.loc; @@ -101,8 +101,7 @@ rec { let ss = opt.type.getSubOptions opt.loc; in if ss != {} then optionAttrSetToDocList' opt.loc ss else []; in - # FIXME: expensive, O(n^2) - [ docOption ] ++ subOptions ++ rest) [] (collect isOption options); + [ docOption ] ++ subOptions) (collect isOption options); /* This function recursively removes all derivation attributes from