@@ -13,6 +13,7 @@ import Control.Monad.ST(runST,ST)
1313import Data.Array.Base
1414import Data.Bits
1515import qualified Data.ByteString as B
16+import qualified Data.ByteString.Unsafe as B
1617import Data.ByteString.Internal(ByteString(..),mallocByteString,memcpy)
1718import qualified Data.List as L
1819import Data.Word(Word8, Word16, Word32)
@@ -129,7 +130,7 @@ stream_bs ASCII bs = Stream next 0 (B.length bs)
129130 | otherwise = Yield (unsafeChr8 x1) (i+1)
130131 where
131132 l = B.length bs
132− x1 = B.index bs i
133+ x1 = B.unsafeIndex bs i
133134stream_bs Utf8 bs = Stream next 0 (B.length bs)
134135 where
135136 {-# INLINE next #-}
@@ -146,7 +147,7 @@ stream_bs Utf8 bs = Stream next 0 (B.length bs)
146147 x2 = index (i + 1)
147148 x3 = index (i + 2)
148149 x4 = index (i + 3)
149− index = B.index bs
150+ index = B.unsafeIndex bs
150151stream_bs Utf16LE bs = Stream next 0 (B.length bs)
151152 where
152153 {-# INLINE next #-}
@@ -161,7 +162,7 @@ stream_bs Utf16LE bs = Stream next 0 (B.length bs)
161162 x2 :: Word16
162163 x2 = (shiftL (index (i + 3)) 8) + (index (i + 2))
163164 l = B.length bs
164− index = fromIntegral . B.index bs :: Int -> Word16
165+ index = fromIntegral . B.unsafeIndex bs :: Int -> Word16
165166stream_bs Utf16BE bs = Stream next 0 (B.length bs)
166167 where
167168 {-# INLINE next #-}
@@ -176,7 +177,7 @@ stream_bs Utf16BE bs = Stream next 0 (B.length bs)
176177 x2 :: Word16
177178 x2 = (shiftL (index (i + 2)) 8) + (index (i + 3))
178179 l = B.length bs
179− index = fromIntegral . B.index bs
180+ index = fromIntegral . B.unsafeIndex bs
180181stream_bs Utf32BE bs = Stream next 0 (B.length bs)
181182 where
182183 {-# INLINE next #-}
@@ -191,7 +192,7 @@ stream_bs Utf32BE bs = Stream next 0 (B.length bs)
191192 x2 = index (i+1)
192193 x3 = index (i+2)
193194 x4 = index (i+3)
194− index = fromIntegral . B.index bs :: Int -> Word32
195+ index = fromIntegral . B.unsafeIndex bs :: Int -> Word32
195196stream_bs Utf32LE bs = Stream next 0 (B.length bs)
196197 where
197198 {-# INLINE next #-}
@@ -206,7 +207,7 @@ stream_bs Utf32LE bs = Stream next 0 (B.length bs)
206207 x2 = index $ i+1
207208 x3 = index $ i+2
208209 x4 = index $ i+3
209− index = fromIntegral . B.index bs :: Int -> Word32
210+ index = fromIntegral . B.unsafeIndex bs :: Int -> Word32
210211{-# INLINE [0] stream_bs #-}
211212
212213-- | /O(n)/ Convert a Stream Char into a Stream Word8 using the specified encoding standard.