mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-12 05:16:25 +03:00
lib: refactor filterAttrs
`filter` is a primop which is designed for this task, and it saves the allocation of some singleton lists here.
This commit is contained in:
parent
83e1488c6d
commit
1de8e07216
1 changed files with 2 additions and 2 deletions
|
@ -7,7 +7,7 @@ let
|
||||||
inherit (builtins) head length;
|
inherit (builtins) head length;
|
||||||
inherit (lib.trivial) isInOldestRelease mergeAttrs warn warnIf;
|
inherit (lib.trivial) isInOldestRelease mergeAttrs warn warnIf;
|
||||||
inherit (lib.strings) concatStringsSep concatMapStringsSep escapeNixIdentifier sanitizeDerivationName;
|
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
|
in
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
@ -644,7 +644,7 @@ rec {
|
||||||
filterAttrs =
|
filterAttrs =
|
||||||
pred:
|
pred:
|
||||||
set:
|
set:
|
||||||
removeAttrs set (concatMap (name: if pred name set.${name} then [ ] else [ name ]) (attrNames set));
|
removeAttrs set (filter (name: ! pred name set.${name}) (attrNames set));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Filter an attribute set recursively by removing all attributes for
|
Filter an attribute set recursively by removing all attributes for
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue