From feb74fca3771f93fabdc86b6f682cbe276e487ad Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Tue, 26 May 2026 13:37:16 -0400 Subject: [PATCH] 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. --- lib/gvariant.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/gvariant.nix b/lib/gvariant.nix index 3749e4c82d3b..810e0db799bd 100644 --- a/lib/gvariant.nix +++ b/lib/gvariant.nix @@ -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 // {