Bryan O'Sullivan avatar Bryan O'Sullivan committed 067380b

Get rid of the old decode function

Comments (0)

Files changed (2)

Data/Text/Encoding.hs

     -- * Decoding ByteStrings to Text
       decodeASCII
     , decodeUtf8
-    , decodeUtf8'
     , decodeUtf16LE
     , decodeUtf16BE
     , decodeUtf32LE
     , decodeUtf32BE
     -- ** Controllable error handling
     , decodeUtf8With
-    , decodeUtf8With'
     , decodeUtf16LEWith
     , decodeUtf16BEWith
     , decodeUtf32LEWith
 decodeASCII bs = F.unstream (E.streamASCII bs)
 {-# INLINE decodeASCII #-}
 
--- | Decode a 'ByteString' containing UTF-8 encoded text.
 decodeUtf8With :: OnDecodeError -> ByteString -> Text
-decodeUtf8With onErr bs = F.unstream (E.streamUtf8 onErr bs)
-{-# INLINE decodeUtf8With #-}
-
--- | Decode a 'ByteString' containing UTF-8 encoded text.
-decodeUtf8 :: ByteString -> Text
-decodeUtf8 = decodeUtf8With strictDecode
-{-# INLINE decodeUtf8 #-}
-
-decodeUtf8With' :: OnDecodeError -> ByteString -> Text
-decodeUtf8With' onErr bs = textP (fst a) 0 (snd a)
+decodeUtf8With onErr bs = textP (fst a) 0 (snd a)
  where
   a   = A.run2 (A.new len >>= outer 0 0)
   len = B.length bs
                          Just c -> do
                            w <- unsafeWrite arr n c
                            go (n+w) (m+1)
-  desc = "Data.Text.Encoding.encodeUtf8: Invalid UTF-8 stream"
-{-# INLINE[0] decodeUtf8With' #-}
+  desc = "Data.Text.Encoding.decodeUtf8: Invalid UTF-8 stream"
+{-# INLINE[0] decodeUtf8With #-}
 
 -- | Decode a 'ByteString' containing UTF-8 encoded text.
-decodeUtf8' :: ByteString -> Text
-decodeUtf8' = decodeUtf8With' strictDecode
-{-# INLINE[0] decodeUtf8' #-}
+decodeUtf8 :: ByteString -> Text
+decodeUtf8 = decodeUtf8With strictDecode
+{-# INLINE[0] decodeUtf8 #-}
 
-{-# RULES "STREAM stream/decodeUtf8' fusion" [1]
-    forall bs. F.stream (decodeUtf8' bs) = E.streamUtf8 strictDecode bs #-}
+{-# RULES "STREAM stream/decodeUtf8 fusion" [1]
+    forall bs. F.stream (decodeUtf8 bs) = E.streamUtf8 strictDecode bs #-}
 
 -- | Encode text using UTF-8 encoding.
 encodeUtf8 :: Text -> ByteString

tests/benchmarks/DecodeUtf8.hs

   bs <- B.hGetContents h
   rnf (T.decodeUtf8 bs) `seq` return ()
 
-strict_ h = do
-  bs <- B.hGetContents h
-  rnf (T.decodeUtf8' bs) `seq` return ()
-
 strict_len h = do
   bs <- B.hGetContents h
+  print . T.length . T.decodeUtf8 $ bs
+
+strict_init_len h = do
+  bs <- B.hGetContents h
   print . T.length . T.init . T.decodeUtf8 $ bs
 
-strict__len h = do
-  bs <- B.hGetContents h
-  print . T.length . T.init . T.decodeUtf8' $ bs
-
 strict_io h = do
   hSetEncoding h utf8
   t <- T.hGetContents h
   rnf t `seq` return ()
 
+strict_len_io h = do
+  hSetEncoding h utf8
+  t <- T.hGetContents h
+  print (T.length t)
+
 lazy h = do
   bs <- BL.hGetContents h
   rnf (TL.decodeUtf8 bs) `seq` return ()
   h <- openFile name ReadMode
   case kind of
     "strict" -> strict h
-    "strict_" -> strict_ h
-    "strict__len" -> strict__len h
     "strict_len" -> strict_len h
+    "strict_init_len" -> strict_init_len h
     "strict_io" -> strict_io h
+    "strict_len_io" -> strict_len_io h
     "lazy" -> lazy h
     "lazy_io" -> lazy_io h
     "string" -> string h
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.