on master help sign in
Get rid of old lazy UTF-8 function

--HG-- extra : convert_revision : b235a034aae275df82a794769276fae8a222be15

commitd952f7bec8cb97bc976927a2430949e950712eb6 authorBryan O'Sullivan <bos@serpentine.com> dateFri 15 Oct 2010, 03:53 (16 years ago) parentbe727f0
2 files changed+5−32
Data/Text/Lazy/Encoding.hs+5−17 tests/benchmarks/DecodeUtf8.hs−15
Data/Text/Lazy/Encoding.hs+5−17
@@ -20,14 +20,12 @@ module Data.Text.Lazy.Encoding
2020 -- * Decoding ByteStrings to Text
2121 decodeASCII
2222 , decodeUtf8
23− , decodeUtf8'
2423 , decodeUtf16LE
2524 , decodeUtf16BE
2625 , decodeUtf32LE
2726 , decodeUtf32BE
2827 -- ** Controllable error handling
2928 , decodeUtf8With
30− , decodeUtf8With'
3129 , decodeUtf16LEWith
3230 , decodeUtf16BEWith
3331 , decodeUtf32LEWith
@@ -60,17 +58,7 @@ decodeASCII bs = foldr (chunk . TE.decodeASCII) empty (B.toChunks bs)
6058
6159-- | Decode a 'ByteString' containing UTF-8 encoded text.
6260decodeUtf8With :: OnDecodeError -> B.ByteString -> Text
63−decodeUtf8With onErr bs = F.unstream (E.streamUtf8 onErr bs)
64−{-# INLINE decodeUtf8With #-}
65−
66−-- | Decode a 'ByteString' containing UTF-8 encoded text.
67−decodeUtf8 :: B.ByteString -> Text
68−decodeUtf8 = decodeUtf8With strictDecode
69−{-# INLINE decodeUtf8 #-}
70−
71−-- | Decode a 'ByteString' containing UTF-8 encoded text.
72−decodeUtf8With' :: OnDecodeError -> B.ByteString -> Text
73−decodeUtf8With' onErr bs0 = fast bs0
61+decodeUtf8With onErr bs0 = fast bs0
7462 where
7563 decode = TE.decodeUtf8With onErr
7664 fast (B.Chunk p ps) | isComplete p = chunk (decode p) (fast ps)
@@ -104,12 +92,12 @@ decodeUtf8With' onErr bs0 = fast bs0
10492 where len = S.length bs
10593 ix n = S.unsafeIndex bs (len-n)
10694 desc = "Data.Text.Lazy.Encoding.decodeUtf8With: Invalid UTF-8 stream"
107−{-# INLINE[0] decodeUtf8With' #-}
95+{-# INLINE[0] decodeUtf8With #-}
10896
10997-- | Decode a 'ByteString' containing UTF-8 encoded text.
110−decodeUtf8' :: B.ByteString -> Text
111−decodeUtf8' = decodeUtf8With' strictDecode
112−{-# INLINE[0] decodeUtf8' #-}
98+decodeUtf8 :: B.ByteString -> Text
99+decodeUtf8 = decodeUtf8With strictDecode
100+{-# INLINE[0] decodeUtf8 #-}
113101
114102-- This rule seems to cause performance loss.
115103{- RULES "LAZY STREAM stream/decodeUtf8' fusion" [1]
tests/benchmarks/DecodeUtf8.hs−15
@@ -37,26 +37,14 @@ lazy h = do
3737 bs <- BL.hGetContents h
3838 rnf (TL.decodeUtf8 bs) `seq` return ()
3939
40−lazy_ h = do
41− bs <- BL.hGetContents h
42− rnf (TL.decodeUtf8' bs) `seq` return ()
43−
4440lazy_len h = do
4541 bs <- BL.hGetContents h
4642 print . TL.length . TL.decodeUtf8 $ bs
4743
48−lazy__len h = do
49− bs <- BL.hGetContents h
50− print . TL.length . TL.decodeUtf8' $ bs
51−
5244lazy_init_len h = do
5345 bs <- BL.hGetContents h
5446 print . TL.length . TL.init . TL.decodeUtf8 $ bs
5547
56−lazy__init_len h = do
57− bs <- BL.hGetContents h
58− print . TL.length . TL.init . TL.decodeUtf8' $ bs
59−
6048lazy_io h = do
6149 hSetEncoding h utf8
6250 t <- TL.hGetContents h
@@ -109,9 +97,6 @@ main = do
10997 "lazy" -> lazy h
11098 "lazy_len" -> lazy_len h
11199 "lazy_init_len" -> lazy_init_len h
112− "lazy__init_len" -> lazy__init_len h
113− "lazy_" -> lazy_ h
114− "lazy__len" -> lazy__len h
115100 "lazy_io" -> lazy_io h
116101 "lazy_len_io" -> lazy_len_io h
117102 "string" -> string h