mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-14 18:26:16 +02:00
00c993f48b
nixpkgs can save a good bit of eval memory with this primop. zipAttrsWith is used quite a bit around nixpkgs (eg in the form of recursiveUpdate), but the most costly application for this primop is in the module system. it improves the implementation of zipAttrsWith from nixpkgs by not checking an attribute multiple times if it occurs more than once in the input list, allocates less values and set elements, and just avoids many a temporary object in general. nixpkgs has a more generic version of this operation, zipAttrsWithNames, but this version is only used once so isn't suitable for being the base of a new primop. if it were to be used more we should add a second primop instead.
9 lines
194 B
Nix
9 lines
194 B
Nix
with import ./lib.nix;
|
|
|
|
let
|
|
str = builtins.hashString "sha256" "test";
|
|
in
|
|
builtins.zipAttrsWith
|
|
(n: v: { inherit n v; })
|
|
(map (n: { ${builtins.substring n 1 str} = n; })
|
|
(range 0 31))
|