on master help sign in
Use single byte size for enum types in genericSizeOf

But still use non-zero size for a single unit constructor.

commit909152e106c13d69952a99b9499f3727e8c130f6 authorRanjeet Ranjan <ranjeetr@composewell.com> dateSat 18 Feb 2023, 07:10 (4 years ago) parentc277561
1 file changed+4−2
core/src/Streamly/Internal/Data/Unboxed.hs+4−2
core/src/Streamly/Internal/Data/Unboxed.hs+4−2
@@ -647,7 +647,7 @@ instance SizeOfRep V1 where
647647-- required to encode the type as only the constructor tag is stored.
648648instance SizeOfRep U1 where
649649 {-# INLINE sizeOfRep #-}
650− sizeOfRep _ = 1
650+ sizeOfRep _ = 0
651651
652652-- Product type
653653instance (SizeOfRep f, SizeOfRep g) => SizeOfRep (f :*: g) where
@@ -687,7 +687,9 @@ instance (MaxArity256 (SumArity (f :+: g)), SizeOfRepSum f, SizeOfRepSum g) =>
687687
688688{-# INLINE genericSizeOf #-}
689689genericSizeOf :: forall a. (SizeOfRep (Rep a)) => Proxy a -> Int
690−genericSizeOf _ = sizeOfRep (undefined :: Rep a x)
690+genericSizeOf _ =
691+ let s = sizeOfRep (undefined :: Rep a x)
692+ in if s == 0 then 1 else s
691693
692694--------------------------------------------------------------------------------
693695-- Generic poke