kazu-yamamoto/logger

Suboptimal ToLogStr instance for Lazy ByteString

Closed this issue · 4 comments

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.

I believe this is fixed in the most recent version

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)

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

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