@@ -46,7 +46,7 @@ import qualified Data.Text as T
46import Data.Text.Fusion (stream, unstream)
46import Data.Text.Fusion (stream, unstream)
47import Data.Text.Fusion.Internal (Step(..), Stream(..))
47import Data.Text.Fusion.Internal (Step(..), Stream(..))
48import Data.Text.Fusion.Size (exactSize, maxSize)
48import Data.Text.Fusion.Size (exactSize, maxSize)
49−import Data.Text.IO.Internal (getSomeCharacters, hGetLineWith, unpack, unpack_nl)
49+import Data.Text.IO.Internal (hGetLineWith, readChunk)
50import Data.Text.Unsafe (inlinePerformIO)
50import Data.Text.Unsafe (inlinePerformIO)
51import Foreign.Storable (peekElemOff)
51import Foreign.Storable (peekElemOff)
52import GHC.IO.Buffer (Buffer(..), BufferState(..), CharBufElem, CharBuffer,
52import GHC.IO.Buffer (Buffer(..), BufferState(..), CharBufElem, CharBuffer,
@@ -99,12 +99,7 @@ hGetContents h = wantReadableHandle "hGetContents" h $ \hh -> do
99 readAll hh@Handle__{..} = do
99 readAll hh@Handle__{..} = do
100 buf <- readIORef haCharBuffer
100 buf <- readIORef haCharBuffer
101 let readChunks = do
101 let readChunks = do
102− buf'@Buffer{..} <- getSomeCharacters hh buf
102+ t <- readChunk hh buf
103− (t,r) <- if haInputNL == CRLF
104− then unpack_nl bufRaw bufL bufR
105− else do t <- unpack bufRaw bufL bufR
107− writeIORef haCharBuffer (bufferAdjustL r buf')
108 (hh',ts) <- readAll hh
103 (hh',ts) <- readAll hh
109 return (hh', t:ts)
104 return (hh', t:ts)
110 readChunks `catch` \e -> do
105 readChunks `catch` \e -> do
@@ -115,7 +110,7 @@ hGetContents h = wantReadableHandle "hGetContents" h $ \hh -> do
115 else (hh', [T.singleton '\r'])
110 else (hh', [T.singleton '\r'])
116 else throw (augmentIOError e "hGetContents" h)
111 else throw (augmentIOError e "hGetContents" h)
119-- | Read a single line from a handle.
114-- | Read a single line from a handle.
120hGetLine :: Handle -> IO Text
115hGetLine :: Handle -> IO Text
121#if __GLASGOW_HASKELL__ <= 610
116#if __GLASGOW_HASKELL__ <= 610