From bfaa9426c0e70b387f58bce6248b454b556018c2 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Wed, 3 Nov 2021 19:05:26 +0100 Subject: lib/modules: Short-circuit unmatchedDefns earlier --- lib/modules.nix | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'lib/modules.nix') diff --git a/lib/modules.nix b/lib/modules.nix index b2ae51c8e618a..4bbf2947bc4e9 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -430,26 +430,27 @@ rec { # an attrset 'name' => list of unmatched definitions for 'name' unmatchedDefnsByName = + # Propagate all unmatched definitions from nested option sets + mapAttrs (n: v: v.unmatchedDefns) resultsByName + # Plus the definitions for the current prefix that don't have a matching option + // removeAttrs defnsByName' (attrNames matchedOptions); + in { + inherit matchedOptions; + + # Transforms unmatchedDefnsByName into a list of definitions + unmatchedDefns = if configs == [] then # When no config values exist, there can be no unmatched config, so # we short circuit and avoid evaluating more _options_ than necessary. - {} + [] else - # Propagate all unmatched definitions from nested option sets - mapAttrs (n: v: v.unmatchedDefns) resultsByName - # Plus the definitions for the current prefix that don't have a matching option - // removeAttrs defnsByName' (attrNames matchedOptions); - in { - inherit matchedOptions; - - # Transforms unmatchedDefnsByName into a list of definitions - unmatchedDefns = concatLists (mapAttrsToList (name: defs: - map (def: def // { - # Set this so we know when the definition first left unmatched territory - prefix = [name] ++ (def.prefix or []); - }) defs - ) unmatchedDefnsByName); + concatLists (mapAttrsToList (name: defs: + map (def: def // { + # Set this so we know when the definition first left unmatched territory + prefix = [name] ++ (def.prefix or []); + }) defs + ) unmatchedDefnsByName); }; /* Merge multiple option declarations into a single declaration. In -- cgit 1.4.1