diff options
| author | Silvan Mosberger <contact@infinisil.com> | 2024-11-01 11:54:20 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-01 11:54:20 +0100 |
| commit | 5690833b4f1e1d0275767d6496321bfb6fc84ae6 (patch) | |
| tree | 42dcd14be036c29320c1781e8cd3c4870a6cf544 /lib/attrsets.nix | |
| parent | vimPlugins.fastaction-nvim: init at 2024-10-26 (#352744) (diff) | |
| parent | lib: refactor `filterAttrs` (diff) | |
| download | nixpkgs-5690833b4f1e1d0275767d6496321bfb6fc84ae6.tar.gz | |
lib: improve filterAttrs (#345547)
Diffstat (limited to 'lib/attrsets.nix')
| -rw-r--r-- | lib/attrsets.nix | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/attrsets.nix b/lib/attrsets.nix index 7b8feb4fe89b..3001e4ec93b5 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -7,7 +7,7 @@ let inherit (builtins) head length; inherit (lib.trivial) oldestSupportedReleaseIsAtLeast mergeAttrs warn warnIf; inherit (lib.strings) concatStringsSep concatMapStringsSep escapeNixIdentifier sanitizeDerivationName; - inherit (lib.lists) foldr foldl' concatMap elemAt all partition groupBy take foldl; + inherit (lib.lists) filter foldr foldl' concatMap elemAt all partition groupBy take foldl; in rec { @@ -644,8 +644,7 @@ rec { filterAttrs = pred: set: - listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set)); - + removeAttrs set (filter (name: ! pred name set.${name}) (attrNames set)); /** Filter an attribute set recursively by removing all attributes for |
