mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
lib.attrsets.concatMapAttrs: rewrite for efficiency
(cherry picked from commit 1c53d25f58)
This commit is contained in:
parent
647b7bfce7
commit
aed9f7b95d
1 changed files with 13 additions and 8 deletions
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
let
|
||||
inherit (builtins) head length;
|
||||
inherit (lib.trivial) mergeAttrs;
|
||||
inherit (lib.strings)
|
||||
concatStringsSep
|
||||
concatMapStringsSep
|
||||
|
|
@ -13,16 +12,18 @@ let
|
|||
sanitizeDerivationName
|
||||
;
|
||||
inherit (lib.lists)
|
||||
filter
|
||||
foldr
|
||||
foldl'
|
||||
all
|
||||
concatLists
|
||||
concatMap
|
||||
elemAt
|
||||
all
|
||||
partition
|
||||
groupBy
|
||||
take
|
||||
filter
|
||||
foldl
|
||||
foldl'
|
||||
foldr
|
||||
groupBy
|
||||
partition
|
||||
reverseList
|
||||
take
|
||||
;
|
||||
in
|
||||
|
||||
|
|
@ -370,7 +371,11 @@ rec {
|
|||
|
||||
:::
|
||||
*/
|
||||
concatMapAttrs = f: v: foldl' mergeAttrs { } (attrValues (mapAttrs f v));
|
||||
concatMapAttrs =
|
||||
f: v:
|
||||
listToAttrs (
|
||||
concatLists (reverseList (mapAttrsToList (name: value: attrsToList (f name value)) v))
|
||||
);
|
||||
|
||||
/**
|
||||
Update or set specific paths of an attribute set.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue