on master help sign in
Shuffle around buffer management

--HG-- extra : convert_revision : b975674e7c809d6a4897396e7f881f39257fd026

commit5ac1d3ae78fb611c3fd41d7192b112dd767874a6 authorBryan O'Sullivan <bos@serpentine.com> dateThu 26 Aug 2010, 01:19 (16 years ago) parent5d980d0
1 file changed+5−4
Data/Text/IO.hs+5−4
Data/Text/IO.hs+5−4
@@ -97,15 +97,16 @@ hGetContents h = do
9797 return (hh'{haType=ClosedHandle},T.concat ts)
9898 where
9999 readAll hh@Handle__{..} = do
100− buf <- readIORef haCharBuffer
101100 let readChunks = do
102− t <- readChunk hh buf
103− (hh',ts) <- readAll hh
101+ t <- readChunk hh =<< readIORef haCharBuffer
102+ (hh',ts) <- readChunks
104103 return (hh', t:ts)
105104 readChunks `catch` \e -> do
106105 (hh', _) <- hClose_help hh
107106 if isEOFError e
108− then return $ if isEmptyBuffer buf
107+ then do
108+ buf <- readIORef haCharBuffer
109+ return $ if isEmptyBuffer buf
109110 then (hh', [])
110111 else (hh', [T.singleton '\r'])
111112 else throw (augmentIOError e "hGetContents" h)