kazu-yamamoto / logger

A fast logging system for Haskell
159 stars 68 forks source link

Suboptimal ToLogStr instance for Lazy ByteString #169

Closed andrewthad closed 5 years ago

andrewthad commented 5 years ago

The ToLogStr instance for lazy bytestring converts the lazy bytestring to a strict bytestring. This is unnecessary since Data.ByteString.Builder.lazyByteString pulls the chunks of a lazy bytestring straight into a builder.

chessai commented 5 years ago

I believe this is fixed in the most recent version

andrewthad commented 5 years ago

Nope, the instance still looks just like it does when I opened this issue:

instance ToLogStr BL.ByteString where
    toLogStr = toLogStr . S8.concat . BL.toChunks

Preferable would be:

instance ToLogStr BL.ByteString where
    toLogStr b = LogStr (fromIntegral (BL.length b)) (B.lazyByteString b)
chessai commented 5 years ago

@andrewthad i looked at the wrong instance. so nevermind then

kazu-yamamoto commented 5 years ago

@andrewthad Sorry, I didn't notice this. Could you send a PR?