lib.strings: remove assertMsg usage

assertMsg 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:
Eman Resu
2026-05-26 13:23:00 -04:00
parent 4ff2645579
commit 855f2d0435
+3 -2
View File
@@ -2532,8 +2532,9 @@ rec {
strw = lib.stringLength str;
reqWidth = width - (lib.stringLength filler);
in
assert lib.assertMsg (strw <= width)
"fixedWidthString: requested string length (${toString width}) must not be shorter than actual length (${toString strw})";
assert
strw <= width
|| throw "fixedWidthString: requested string length (${toString width}) must not be shorter than actual length (${toString strw})";
if strw == width then str else filler + fixedWidthString reqWidth filler str;
/**