[Haskell-cafe] Attoparsec.ByteString.Char8 or Attoparsec.ByteString for diff output?

Viktor Dukhovni ietf-dane at dukhovni.org
Mon Feb 20 20:38:55 UTC 2023


On Mon, Feb 20, 2023 at 03:58:10PM -0400, Pedro B. wrote:

> You made me realize that I can use "word8 _a" instead of  "char 'a'" and 
> almost have no need for the Char8 combinators. I'll probably do that and 
> only use  "decimal" from Char8 to parse integers, which I need to parse 
> line ranges such as "2,10".

That's the sort of thing I was hinting at.

> I still have a doubt though: given that I only match specific characters 
> generated by diff, do I gain something by not using Char8? Performance, 
> perhaps?

In most case performance gains are likely to be marginal at best.  The
compiler should be able to optimise away most of the possible overhead
of Char<->Word8 coversions, but perhaps in some corner cases you might
see better performance.  Write maintainable code, and only if profiling
shows opportunities for meaningful performance gains consider
optimisations that might make the code less clear.

-- 
    Viktor.


More information about the Haskell-Cafe mailing list