@@ -3075,20 +3075,27 @@ decodeUtf8With cfm (Stream step state) = Stream step' (FreshPoint 0 0 state)
30753075 return $
30763076 case r of
30773077 Yield x s ->
3078− let (Tuple' sv cp) =
3079− decode statePtr codepointPtr x
3080− in case sv of
3081− 12 ->
3082− Skip $
3083− transliterateOrError
3084− "Streamly.Streams.StreamD.decodeUtf8With: Invalid UTF8 codepoint encountered"
3085− (FreshPoint 0 0 s)
3086− 0 ->
3087− Skip $
3088− YieldAndContinue
3089− (unsafeChr (fromIntegral cp))
3090− (FreshPoint cp sv s)
3091− _ -> Skip (FreshPoint cp sv s)
3078+ if statePtr == 0 && x <= 0x7f
3079+ then
3080+ Skip $
3081+ YieldAndContinue
3082+ (unsafeChr (fromIntegral x))
3083+ (FreshPoint 0 0 s)
3084+ else
3085+ let (Tuple' sv cp) =
3086+ decode statePtr codepointPtr x
3087+ in case sv of
3088+ 12 ->
3089+ Skip $
3090+ transliterateOrError
3091+ "Streamly.Streams.StreamD.decodeUtf8With: Invalid UTF8 codepoint encountered"
3092+ (FreshPoint 0 0 s)
3093+ 0 ->
3094+ Skip $
3095+ YieldAndContinue
3096+ (unsafeChr (fromIntegral cp))
3097+ (FreshPoint cp sv s)
3098+ _ -> Skip (FreshPoint cp sv s)
30923099 Skip s -> Skip (FreshPoint codepointPtr statePtr s)
30933100 Stop ->
30943101 if statePtr /= 0
@@ -3162,20 +3169,26 @@ decodeUtf8ArraysWith cfm (Stream step state) =
31623169 r <- peek p
31633170 touchForeignPtr startf
31643171 return r
3165− let (Tuple' sv cp) = decode statePtr codepointPtr x
3166− return $
3167− case sv of
3168− 12 ->
3169− Skip $
3170− transliterateOrError
3171− "Streamly.Streams.StreamD.decodeUtf8ArraysWith: Invalid UTF8 codepoint encountered"
3172− (InnerLoop 0 0 st startf (p `plusPtr` 1) end)
3173− 0 ->
3174− Skip $
3175− YAndC
3176− (unsafeChr (fromIntegral cp))
3177− (InnerLoop cp sv st startf (p `plusPtr` 1) end)
3178− _ -> Skip (InnerLoop cp sv st startf (p `plusPtr` 1) end)
3172+ if statePtr == 0 && x <= 0x7f
3173+ then
3174+ return $ Skip $ YAndC
3175+ (unsafeChr (fromIntegral x))
3176+ (InnerLoop 0 0 st startf (p `plusPtr` 1) end)
3177+ else do
3178+ let (Tuple' sv cp) = decode statePtr codepointPtr x
3179+ return $
3180+ case sv of
3181+ 12 ->
3182+ Skip $
3183+ transliterateOrError
3184+ "Streamly.Streams.StreamD.decodeUtf8ArraysWith: Invalid UTF8 codepoint encountered"
3185+ (InnerLoop 0 0 st startf (p `plusPtr` 1) end)
3186+ 0 ->
3187+ Skip $
3188+ YAndC
3189+ (unsafeChr (fromIntegral cp))
3190+ (InnerLoop cp sv st startf (p `plusPtr` 1) end)
3191+ _ -> Skip (InnerLoop cp sv st startf (p `plusPtr` 1) end)
31793192 step' _ (YAndC c s) = return $ Yield c s
31803193 step' _ D = return Stop
31813194