optionAttrSetToDocList: O(n^2) -> O(n)

This shaves about 10% off memory consumption of NixOS evaluation.
This commit is contained in:
Eelco Dolstra 2015-07-23 16:32:52 +02:00
parent 3cd5fd8bb3
commit f14dab05d6

View File

@ -83,7 +83,7 @@ rec {
optionAttrSetToDocList = optionAttrSetToDocList' []; optionAttrSetToDocList = optionAttrSetToDocList' [];
optionAttrSetToDocList' = prefix: options: optionAttrSetToDocList' = prefix: options:
fold (opt: rest: concatMap (opt:
let let
docOption = rec { docOption = rec {
name = showOption opt.loc; name = showOption opt.loc;
@ -101,8 +101,7 @@ rec {
let ss = opt.type.getSubOptions opt.loc; let ss = opt.type.getSubOptions opt.loc;
in if ss != {} then optionAttrSetToDocList' opt.loc ss else []; in if ss != {} then optionAttrSetToDocList' opt.loc ss else [];
in in
# FIXME: expensive, O(n^2) [ docOption ] ++ subOptions) (collect isOption options);
[ docOption ] ++ subOptions ++ rest) [] (collect isOption options);
/* This function recursively removes all derivation attributes from /* This function recursively removes all derivation attributes from