replace-megaparsec
replace-megaparsec copied to clipboard
fast bytestring building
https://hackage.haskell.org/package/bytestring-tree-builder
According to the benchmarks this builder implementation beats all the alternatives. It is especially well-suited for generating strict bytestrings, beating the standard builder by at least the factor of 4.
I'm not sure that bytestring-tree-builder is better than ByteString mconcat.
Maybe we should have a documentation section about making a lazy builder version of streamEditT. “If you want to construct the replaced stream as a lazy builder, consider using splitCap directly instead of using streamEditT. Write your pattern-matching parser sep so that it returns a Builder of your choice. Then build the output stream from the [Either ByteString Builder] list produced by splitCap. You should be able to efficiently build from the strict Left ByteString sections, as they are essentially just a pair of offsets delimiting a section of the input ByteString.”