Unverified Commit 03796993 authored by Jörg Thalheim's avatar Jörg Thalheim Committed by GitHub
Browse files

lib/modules: short-circuit mergeDefinitions for plain singletons (#509195)

parents d189cfcc a3b13a82
Loading
Loading
Loading
Loading
+27 −4
Original line number Diff line number Diff line
@@ -1223,6 +1223,29 @@ let
          else
            defsFiltered.values;
      in
      # Fast path: the overwhelming majority of options have exactly one
      # definition whose value carries no property wrapper
      # (mkIf/mkMerge/mkOverride/mkOrder/definition). In that case the
      # discharge/filter/sort pipeline above is a no-op but still allocates
      # several intermediate lists and closures. Detect it up front and hand
      # the original singleton straight to the type merge. The let-bindings
      # above are lazy and thus never forced on this branch.
      if
        length defs == 1
        && (
          let
            d = head defs;
          in
          addErrorContext "while evaluating definitions from `${d.file}':" (
            !(isAttrs d.value && d.value ? _type)
          )
        )
      then
        {
          values = defs;
          highestPrio = defaultOverridePriority;
        }
      else
        {
          values = defsSorted;
          inherit (defsFiltered) highestPrio;