@@ -3010,11 +3010,11 @@ replacementChar :: Char
30103010replacementChar = '\xFFFD'
30113011
30123012type CodePoint = Word32
3013−type DecoderState = Word32
3013+type DecoderState = Word8
30143014
30153015-- See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
30163016
3017−utf8d :: A.Array Word32
3017+utf8d :: A.Array Word8
30183018utf8d = A.fromList [
30193019 -- The first part of the table maps bytes to character classes that
30203020 -- to reduce the size of the transition table and create bitmasks.
@@ -3037,14 +3037,15 @@ utf8d = A.fromList [
30373037 ]
30383038
30393039{-# INLINE decode #-}
3040−decode :: DecoderState -> CodePoint -> Word32 -> Tuple' DecoderState CodePoint
3040+decode :: DecoderState -> CodePoint -> Word8 -> Tuple' DecoderState CodePoint
30413041decode state codep byte =
3042− let t = utf8d `A.unsafeIndex` (fromIntegral byte)
3042+ let t = utf8d `A.unsafeIndex` fromIntegral byte
30433043 codep' =
30443044 if state /= 0
3045− then (byte .&. 0x3f) .|. (codep `shiftL` 6)
3046− else (0xff `shiftR` (fromIntegral t)) .&. byte
3047− state' = utf8d `A.unsafeIndex` (fromIntegral $ 256 + state + t)
3045+ then (fromIntegral byte .&. 0x3f) .|. (codep `shiftL` 6)
3046+ else (0xff `shiftR` (fromIntegral t)) .&. fromIntegral byte
3047+ state' = utf8d `A.unsafeIndex`
3048+ (256 + fromIntegral state + fromIntegral t)
30483049 in (Tuple' state' codep')
30493050
30503051data FreshPoint s
@@ -3075,7 +3076,7 @@ decodeUtf8With cfm (Stream step state) = Stream step' (FreshPoint 0 0 state)
30753076 case r of
30763077 Yield x s ->
30773078 let (Tuple' sv cp) =
3078− decode statePtr codepointPtr (fromIntegral x)
3079+ decode statePtr codepointPtr x
30793080 in case sv of
30803081 12 ->
30813082 Skip $
@@ -3161,7 +3162,7 @@ decodeUtf8ArraysWith cfm (Stream step state) =
31613162 r <- peek p
31623163 touchForeignPtr startf
31633164 return r
3164− let (Tuple' sv cp) = decode statePtr codepointPtr (fromIntegral x)
3165+ let (Tuple' sv cp) = decode statePtr codepointPtr x
31653166 return $
31663167 case sv of
31673168 12 ->