on master help sign in
Use single byte size for enum types in genericSizeOf
909152eRanjeet Ranjan
core/src/Streamly/Internal/Data/Unboxed.hs+4−2
@@ -647,7 +647,7 @@ instance SizeOfRep V1 where
647-- required to encode the type as only the constructor tag is stored.
647-- required to encode the type as only the constructor tag is stored.
648instance SizeOfRep U1 where
648instance SizeOfRep U1 where
649 {-# INLINE sizeOfRep #-}
649 {-# INLINE sizeOfRep #-}
650− sizeOfRep _ = 1
650+ sizeOfRep _ = 0
651
651
652-- Product type
652-- Product type
653instance (SizeOfRep f, SizeOfRep g) => SizeOfRep (f :*: g) where
653instance (SizeOfRep f, SizeOfRep g) => SizeOfRep (f :*: g) where
@@ -687,7 +687,9 @@ instance (MaxArity256 (SumArity (f :+: g)), SizeOfRepSum f, SizeOfRepSum g) =>
687
687
688{-# INLINE genericSizeOf #-}
688{-# INLINE genericSizeOf #-}
689genericSizeOf :: forall a. (SizeOfRep (Rep a)) => Proxy a -> Int
689genericSizeOf :: forall a. (SizeOfRep (Rep a)) => Proxy a -> Int
690+genericSizeOf _ =
690−genericSizeOf _ = sizeOfRep (undefined :: Rep a x)
691+ let s = sizeOfRep (undefined :: Rep a x)
692+ in if s == 0 then 1 else s
691
693
692--------------------------------------------------------------------------------
694--------------------------------------------------------------------------------
693-- Generic poke
695-- Generic poke