Skip to content

Commit

Permalink
reduced post commit checks
Browse files Browse the repository at this point in the history
  • Loading branch information
BebeSparkelSparkel committed May 1, 2024
1 parent f095348 commit b436ec5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Data/Text/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ chooseGoodBuffering h = do
hGetLine :: Handle -> IO Text
hGetLine = hGetLineWith T.concat


-- | Write a string to a handle.
hPutStr :: Handle -> Text -> IO ()
hPutStr h t = hPutStrInit h $ \mode buf nl -> do
(n, b) <- hPutStr' h mode nl buf 0 (stream t)
when (mode /= NoBuffering) $ let
Buffer{bufRaw,bufSize} = b
in void $ commitBuffer h bufRaw bufSize n False True
let Buffer{bufRaw,bufSize} = b
when (n /= 0) $ void $ commitBuffer h bufRaw bufSize n False True

{-# INLINE hPutStrInit #-}
hPutStrInit :: Handle -> (BufferMode -> CharBuffer -> Newline -> IO ()) -> IO ()
Expand Down
5 changes: 2 additions & 3 deletions src/Data/Text/Lazy/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,8 @@ hPutStr :: Handle -> Text -> IO ()
hPutStr _ L.Empty = pure ()
hPutStr h t = T.hPutStrInit h $ \mode buf nl -> do
(n, b) <- foldlM (\(n, buf) t -> T.hPutStr' h mode nl buf n (stream t)) (0, buf) (L.toChunks t)
when (mode /= NoBuffering && n /= 0) $ let
Buffer{bufRaw,bufSize} = b
in void $ T.commitBuffer h bufRaw bufSize n False True
let Buffer{bufRaw,bufSize} = b
when (n /= 0) $ void $ T.commitBuffer h bufRaw bufSize n False True

-- | Write a string to a handle, followed by a newline.
hPutStrLn :: Handle -> Text -> IO ()
Expand Down

0 comments on commit b436ec5

Please sign in to comment.