mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-07-06 17:13:24 -05:00
lib.gvariant: remove throwIfNot usage
throwIfNot sends our error message through a function call, even if the error condition doesn't trigger. This requires a lot of thunk allocation that can be easily avoided.
This commit is contained in:
parent
079b1a7d07
commit
feb74fca37
1 changed files with 5 additions and 3 deletions
|
|
@ -194,9 +194,11 @@ rec {
|
|||
vs = map mkValue (
|
||||
if elems == [ ] then throw "Please create empty array with mkEmptyArray." else elems
|
||||
);
|
||||
elemType = lib.throwIfNot (lib.all (t: (head vs).type == t) (
|
||||
map (v: v.type) vs
|
||||
)) "Elements in a list should have same type." (head vs).type;
|
||||
elemType =
|
||||
if lib.any (t: (head vs).type != t) (map (v: v.type) vs) then
|
||||
throw "Elements in a list should have same type."
|
||||
else
|
||||
(head vs).type;
|
||||
in
|
||||
mkPrimitive (type.arrayOf elemType) vs
|
||||
// {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue