haskell / text

Haskell library for space- and time-efficient operations over Unicode text.
http://hackage.haskell.org/package/text
BSD 2-Clause "Simplified" License
408 stars 159 forks source link

Integrate UTF-8 `hPutStr` to standard `hPutStr` #589

Closed BebeSparkelSparkel closed 5 months ago

BebeSparkelSparkel commented 7 months ago

Data.Text.IO.Utf8.hPutStr was implemented in #503 and has much better performance than Data.Text.IO.hPutStr when the encoding is "UTF-8" and the neline is LF, so I added it.

Question: Is there a faster way to check for the encoding without checking for string equality?

Lysxia commented 5 months ago

I merged with master (adapting to changes from #600 which moved the logic of hPutStr to Data.Text.Internal.IO.hPutStream) (this PR is squashable, just not rebaseable) and added a comment about why the pointer-equality is fine (I initially thought it had to be guarded as enc `unsafePtrEquality` utf8 || enc == utf8 but convinced myself otherwise).

Bodigrim commented 5 months ago

@Lysxia shall we drop GHC 8.2 CI job?

Bodigrim commented 5 months ago

Thanks a ton!