Fusion.Size: Assert that n >= 0
authorBen Gamari <ben@smart-cactus.org>
Wed, 22 Aug 2018 16:16:23 +0000 (12:16 -0400)
committerBen Gamari <ben@smart-cactus.org>
Wed, 22 Aug 2018 18:53:31 +0000 (14:53 -0400)
Data/Text/Internal/Fusion/Size.hs

index 810fc0f..00cf699 100644 (file)
@@ -61,7 +61,11 @@ charSize c
 
 -- | The 'Size' of @n@ code points.
 codePointsSize :: Int -> Size
-codePointsSize n = Between n (2*n)
+codePointsSize n =
+#if defined(ASSERTS)
+    assert (n >= 0)
+#endif
+    Between n (2*n)
 {-# INLINE codePointsSize #-}
 
 exactSize :: Int -> Size