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.
This commit is contained in:
+3
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user