on iko/ghcjs-patch-master help sign in
Improve shellFor `selectComponents` performance (#1146)
3856d2dTeo Camarasu
builder/shell-for.nix+5−4
@@ -55,19 +55,20 @@ let
55 (builtins.map (x: lib.nameValuePair (x.name) x)
55 (builtins.map (x: lib.nameValuePair (x.name) x)
56 (haskellLib.flatLibDepends {depends = directlySelectedComponents;}));
56 (haskellLib.flatLibDepends {depends = directlySelectedComponents;}));
57
57
58+ isSelectedComponent =
59+ comp: selectedComponentsBitmap."${((haskellLib.dependToLib comp).name or null)}" or false;
58 selectedComponentsBitmap =
60 selectedComponentsBitmap =
59 lib.mapAttrs
61 lib.mapAttrs
60− (_: x: (builtins.any
62+ (_: x: (builtins.any isSelectedComponent x.config.depends))
61− (dep: selectedComponentsBitmap."${(haskellLib.dependToLib dep).name}") x.config.depends))
62 transitiveDependenciesComponents
63 transitiveDependenciesComponents
63 // builtins.listToAttrs (map (x: lib.nameValuePair x.name true) directlySelectedComponents); # base case
64 // builtins.listToAttrs (map (x: lib.nameValuePair x.name true) directlySelectedComponents); # base case
64
65
65 selectedComponents =
66 selectedComponents =
66− lib.filter (x: selectedComponentsBitmap."${x.name}") (lib.attrValues transitiveDependenciesComponents);
67+ lib.filter isSelectedComponent (lib.attrValues transitiveDependenciesComponents);
67
68
68 # Given a list of `depends`, removes those which are selected components
69 # Given a list of `depends`, removes those which are selected components
69 removeSelectedInputs =
70 removeSelectedInputs =
70− lib.filter (input: !(selectedComponentsBitmap."${((haskellLib.dependToLib input).name or null)}" or false));
71+ lib.filter (input: !(isSelectedComponent input));
71
72
72 # The configs of all the selected components
73 # The configs of all the selected components
73 selectedConfigs = map (c: c.config) selectedComponents
74 selectedConfigs = map (c: c.config) selectedComponents
lib/default.nix+1−8
@@ -132,14 +132,7 @@ in {
132 ## flatLibDepends :: Component -> [Package]
132 ## flatLibDepends :: Component -> [Package]
133 flatLibDepends = component:
133 flatLibDepends = component:
134 let
134 let
135− # this is a minor improvement over the "cannot coerce set to string"
136− # error. It will now say:
137− #
138− # > The option `packages.Win32.package.identifier.name' is used but not defined.
139− #
140− # which indicates that the package.Win32 is missing and not defined.
141− getKey = x: if x ? "outPath" then "${x}" else (throw x.identifier.name);
142− makePairs = map (p: rec { key=getKey val; val=(p.components.library or p); });
135+ makePairs = map (p: rec { key=val.name; val=(p.components.library or p); });
143 closure = builtins.genericClosure {
136 closure = builtins.genericClosure {
144 startSet = makePairs component.depends;
137 startSet = makePairs component.depends;
145 operator = {val,...}: makePairs val.config.depends;
138 operator = {val,...}: makePairs val.config.depends;