@@ -3815,6 +3815,10 @@ data WList = WCons !Word8 !WList | WNil
38153815
38163816data EncodeState s = EncodeState s !WList
38173817
3818+-- More yield points improve performance, but I am not sure if they can cause
3819+-- too much code bloat or some trouble with fusion. So keeping only two yield
3820+-- points for now, one for the ascii chars (fast path) and one for all other
3821+-- paths (slow path).
38183822{-# INLINE_NORMAL encodeUtf8 #-}
38193823encodeUtf8 :: Monad m => Stream m Char -> Stream m Word8
38203824encodeUtf8 (Stream step state) = Stream step' (EncodeState state WNil)
@@ -3828,8 +3832,7 @@ encodeUtf8 (Stream step state) = Stream step' (EncodeState state WNil)
38283832 case ord c of
38293833 x
38303834 | x <= 0x7F ->
3831− Skip
3832− (EncodeState s (WCons (fromIntegral x) WNil))
3835+ Yield (fromIntegral x) (EncodeState s WNil)
38333836 | x <= 0x7FF -> Skip (EncodeState s (ord2 c))
38343837 | x <= 0xFFFF ->
38353838 if isSurrogate c