From: simonmar Date: Wed, 30 Apr 2003 08:36:21 +0000 (+0000) Subject: [project @ 2003-04-30 08:36:21 by simonmar] X-Git-Tag: nhc98-1-18-release~662 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=80d0dfad3ab4c715d0af11329f939dc633943a6e;p=ghc-base.git [project @ 2003-04-30 08:36:21 by simonmar] When doing hGetChar on a block-buffered handle, don't wait for the buffer to be completely full before returning a character. This behaviour seems more useful, and matches what hGetLine and hGetContents do. Without this, to do an unbuffered read you have to set the buffering on the Handle to NoBuffering, which adversely affects the performance of writes. With this change, there is now no difference between line buffering and block buffering for read operations. Possibly fillReadBuffer can now be simplified, since the is_line parameter is always True. However, this is a delicate part of the IO library, and I don't want to remove the possiblity of forcing a complete buffer-fill in the future. --- diff --git a/GHC/IO.hs b/GHC/IO.hs index 4b0fa9f..914a55a 100644 --- a/GHC/IO.hs +++ b/GHC/IO.hs @@ -98,7 +98,9 @@ hGetChar handle = new_buf <- fillReadBuffer fd True (haIsStream handle_) buf hGetcBuffered fd ref new_buf BlockBuffering _ -> do - new_buf <- fillReadBuffer fd False (haIsStream handle_) buf + new_buf <- fillReadBuffer fd True (haIsStream handle_) buf + -- ^^^^ + -- don't wait for a completely full buffer. hGetcBuffered fd ref new_buf NoBuffering -> do -- make use of the minimal buffer we already have