@@ -20,14 +20,12 @@ module Data.Text.Lazy.Encoding
20 -- * Decoding ByteStrings to Text
20 -- * Decoding ByteStrings to Text
21 decodeASCII
21 decodeASCII
22 , decodeUtf8
22 , decodeUtf8
24 , decodeUtf16LE
23 , decodeUtf16LE
25 , decodeUtf16BE
24 , decodeUtf16BE
26 , decodeUtf32LE
25 , decodeUtf32LE
27 , decodeUtf32BE
26 , decodeUtf32BE
28 -- ** Controllable error handling
27 -- ** Controllable error handling
29 , decodeUtf8With
28 , decodeUtf8With
31 , decodeUtf16LEWith
29 , decodeUtf16LEWith
32 , decodeUtf16BEWith
30 , decodeUtf16BEWith
33 , decodeUtf32LEWith
31 , decodeUtf32LEWith
@@ -60,17 +58,7 @@ decodeASCII bs = foldr (chunk . TE.decodeASCII) empty (B.toChunks bs)
61-- | Decode a 'ByteString' containing UTF-8 encoded text.
59-- | Decode a 'ByteString' containing UTF-8 encoded text.
62decodeUtf8With :: OnDecodeError -> B.ByteString -> Text
60decodeUtf8With :: OnDecodeError -> B.ByteString -> Text
63−decodeUtf8With onErr bs = F.unstream (E.streamUtf8 onErr bs)
61+decodeUtf8With onErr bs0 = fast bs0
64−{-# INLINE decodeUtf8With #-}
66−-- | Decode a 'ByteString' containing UTF-8 encoded text.
67−decodeUtf8 :: B.ByteString -> Text
68−decodeUtf8 = decodeUtf8With strictDecode
69−{-# INLINE decodeUtf8 #-}
71−-- | Decode a 'ByteString' containing UTF-8 encoded text.
72−decodeUtf8With' :: OnDecodeError -> B.ByteString -> Text
73−decodeUtf8With' onErr bs0 = fast bs0
75 decode = TE.decodeUtf8With onErr
63 decode = TE.decodeUtf8With onErr
76 fast (B.Chunk p ps) | isComplete p = chunk (decode p) (fast ps)
64 fast (B.Chunk p ps) | isComplete p = chunk (decode p) (fast ps)
@@ -104,12 +92,12 @@ decodeUtf8With' onErr bs0 = fast bs0
104 where len = S.length bs
92 where len = S.length bs
105 ix n = S.unsafeIndex bs (len-n)
93 ix n = S.unsafeIndex bs (len-n)
106 desc = "Data.Text.Lazy.Encoding.decodeUtf8With: Invalid UTF-8 stream"
94 desc = "Data.Text.Lazy.Encoding.decodeUtf8With: Invalid UTF-8 stream"
107−{-# INLINE[0] decodeUtf8With' #-}
95+{-# INLINE[0] decodeUtf8With #-}
109-- | Decode a 'ByteString' containing UTF-8 encoded text.
97-- | Decode a 'ByteString' containing UTF-8 encoded text.
110−decodeUtf8' :: B.ByteString -> Text
98+decodeUtf8 :: B.ByteString -> Text
111−decodeUtf8' = decodeUtf8With' strictDecode
99+decodeUtf8 = decodeUtf8With strictDecode
112−{-# INLINE[0] decodeUtf8' #-}
100+{-# INLINE[0] decodeUtf8 #-}
114-- This rule seems to cause performance loss.
102-- This rule seems to cause performance loss.
115{- RULES "LAZY STREAM stream/decodeUtf8' fusion" [1]
103{- RULES "LAZY STREAM stream/decodeUtf8' fusion" [1]