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' = 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