From dd6f1736b78c83593544cf9959750973f2efc93a Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Tue, 26 May 2026 13:31:54 -0400 Subject: [PATCH] lib.gvariant: remove throwIf usage throwIf 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 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/gvariant.nix b/lib/gvariant.nix index f64808347ee8..3749e4c82d3b 100644 --- a/lib/gvariant.nix +++ b/lib/gvariant.nix @@ -191,7 +191,9 @@ rec { mkArray = elems: let - vs = map mkValue (lib.throwIf (elems == [ ]) "Please create empty array with mkEmptyArray." elems); + 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;