haskell / text

Haskell library for space- and time-efficient operations over Unicode text.

Home Page:http://hackage.haskell.org/package/text

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

hPutStr NoBuffer uses base hPutChar for Every Character

BebeSparkelSparkel opened this issue · comments

I was looking at creating a PR for #446 and noticed that for strict text hPutStr the base function GHC.IO.Handle.Text.hPutChar which has a lot of overhead and repeats much work for every character that Data.Text.IO.hPutStr has already done. Is this something that could be improved upon?

This also seems to be the case with lazy text hPutStr except that it repeats work for every chunk instead of every char.

NoBuffering mode is meant to be slow. It does not bear much practical significance, because compiled code uses LineBuffering by default.

I see that now in ghc-internal

            hPutChars handle str        -- v. slow, but we don't care

https://gitlab.haskell.org/ghc/ghc/-/blob/master/libraries/ghc-internal/src/GHC/Internal/IO/Handle/Text.hs#L655