From d6ebd537e5d212995984152d57e16029b3726de5 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 31 Oct 2021 19:10:13 +0100 Subject: lib/modules: Short-circuit unmatchedDefns when configs is empty --- lib/modules.nix | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/modules.nix') diff --git a/lib/modules.nix b/lib/modules.nix index 46ae3f13631..b2ae51c8e61 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -430,10 +430,16 @@ 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); + 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; -- cgit 1.4.1