lib/generators: short-circuit important-field check with any

toHyprconf' tested every important prefix with a non-strict foldl that
always scanned the full list. lib.any expresses the same any-prefix-matches
intent and stops at the first match. Runs once per attribute in the
Hyprland generator.
This commit is contained in:
Austin Horstman
2026-06-17 13:04:43 -05:00
parent a69e55d05b
commit ce68ac6958
+2 -3
View File
@@ -10,11 +10,11 @@
let
inherit (lib)
all
any
concatMapStringsSep
concatStrings
concatStringsSep
filterAttrs
foldl
generators
hasPrefix
isAttrs
@@ -29,8 +29,7 @@
toHyprconf' =
indent: attrs:
let
isImportantField =
n: _: foldl (acc: prev: if hasPrefix prev n then true else acc) false importantPrefixes;
isImportantField = n: _: any (prev: hasPrefix prev n) importantPrefixes;
importantFields = filterAttrs isImportantField attrs;
withoutImportantFields = fields: removeAttrs fields (attrNames importantFields);