Inline some functions on the critical path
This commit is contained in:
parent
9769671260
commit
b479dac8df
@ -29,9 +29,8 @@ rec {
|
|||||||
["x" "y"] applied with some value v returns `x.y = v;' */
|
["x" "y"] applied with some value v returns `x.y = v;' */
|
||||||
setAttrByPath = attrPath: value:
|
setAttrByPath = attrPath: value:
|
||||||
if attrPath == [] then value
|
if attrPath == [] then value
|
||||||
else listToAttrs [(
|
else listToAttrs
|
||||||
nameValuePair (head attrPath) (setAttrByPath (tail attrPath) value)
|
[ { name = head attrPath; value = setAttrByPath (tail attrPath) value; } ];
|
||||||
)];
|
|
||||||
|
|
||||||
|
|
||||||
getAttrFromPath = attrPath: set:
|
getAttrFromPath = attrPath: set:
|
||||||
@ -133,7 +132,7 @@ rec {
|
|||||||
=> { x = "x-foo"; y = "y-bar"; }
|
=> { x = "x-foo"; y = "y-bar"; }
|
||||||
*/
|
*/
|
||||||
mapAttrs = f: set:
|
mapAttrs = f: set:
|
||||||
listToAttrs (map (attr: nameValuePair attr (f attr (getAttr attr set))) (attrNames set));
|
listToAttrs (map (attr: { name = attr; value = f attr (getAttr attr set); }) (attrNames set));
|
||||||
|
|
||||||
|
|
||||||
/* Like `mapAttrs', but allows the name of each attribute to be
|
/* Like `mapAttrs', but allows the name of each attribute to be
|
||||||
|
@ -75,20 +75,23 @@ rec {
|
|||||||
loc' = loc ++ [name];
|
loc' = loc ++ [name];
|
||||||
# Get all submodules that declare ‘name’.
|
# Get all submodules that declare ‘name’.
|
||||||
decls = concatLists (map (m:
|
decls = concatLists (map (m:
|
||||||
optional (hasAttr name m.options)
|
if hasAttr name m.options
|
||||||
{ inherit (m) file; options = getAttr name m.options; }
|
then [ { inherit (m) file; options = getAttr name m.options; } ]
|
||||||
|
else []
|
||||||
) options);
|
) options);
|
||||||
# Get all submodules that define ‘name’.
|
# Get all submodules that define ‘name’.
|
||||||
defns = concatLists (map (m:
|
defns = concatLists (map (m:
|
||||||
optionals (hasAttr name m.config)
|
if hasAttr name m.config
|
||||||
(map (config: { inherit (m) file; inherit config; })
|
then map (config: { inherit (m) file; inherit config; })
|
||||||
(pushDownProperties (getAttr name m.config)))
|
(pushDownProperties (getAttr name m.config))
|
||||||
|
else []
|
||||||
) configs);
|
) configs);
|
||||||
nrOptions = count (m: isOption m.options) decls;
|
nrOptions = count (m: isOption m.options) decls;
|
||||||
# Process mkMerge and mkIf properties.
|
# Process mkMerge and mkIf properties.
|
||||||
defns' = concatMap (m:
|
defns' = concatMap (m:
|
||||||
optionals (hasAttr name m.config)
|
if hasAttr name m.config
|
||||||
(map (m': { inherit (m) file; value = m'; }) (dischargeProperties (getAttr name m.config)))
|
then map (m': { inherit (m) file; value = m'; }) (dischargeProperties (getAttr name m.config))
|
||||||
|
else []
|
||||||
) configs;
|
) configs;
|
||||||
in
|
in
|
||||||
if nrOptions == length decls then
|
if nrOptions == length decls then
|
||||||
@ -123,7 +126,7 @@ rec {
|
|||||||
else
|
else
|
||||||
opt.options // res //
|
opt.options // res //
|
||||||
{ declarations = [opt.file] ++ res.declarations;
|
{ declarations = [opt.file] ++ res.declarations;
|
||||||
options = optionals (opt.options ? options) (toList opt.options.options ++ res.options);
|
options = if opt.options ? options then [(toList opt.options.options ++ res.options)] else [];
|
||||||
}
|
}
|
||||||
) { declarations = []; options = []; } opts;
|
) { declarations = []; options = []; } opts;
|
||||||
|
|
||||||
@ -133,7 +136,8 @@ rec {
|
|||||||
let
|
let
|
||||||
# Process mkOverride properties, adding in the default
|
# Process mkOverride properties, adding in the default
|
||||||
# value specified in the option declaration (if any).
|
# value specified in the option declaration (if any).
|
||||||
defsFinal = filterOverrides (optional (opt ? default) ({ file = head opt.declarations; value = mkOptionDefault opt.default; }) ++ defs);
|
defsFinal = filterOverrides
|
||||||
|
((if opt ? default then [{ file = head opt.declarations; value = mkOptionDefault opt.default; }] else []) ++ defs);
|
||||||
# Type-check the remaining definitions, and merge them if
|
# Type-check the remaining definitions, and merge them if
|
||||||
# possible.
|
# possible.
|
||||||
merged =
|
merged =
|
||||||
|
@ -116,7 +116,7 @@ rec {
|
|||||||
if isList def then
|
if isList def then
|
||||||
listToAttrs (
|
listToAttrs (
|
||||||
flip imap def (elemIdx: elem:
|
flip imap def (elemIdx: elem:
|
||||||
nameValuePair "unnamed-${toString defIdx}.${toString elemIdx}" elem))
|
{ name = "unnamed-${toString defIdx}.${toString elemIdx}"; value = elem; }))
|
||||||
else
|
else
|
||||||
def;
|
def;
|
||||||
listOnly = listOf elemType;
|
listOnly = listOf elemType;
|
||||||
|
Loading…
Reference in New Issue
Block a user