This seems suboptimal from a performance point of view (given MappedWrite's primary use-case is to process the stdout of a process, which could be large in volume).
I happened to spot that the Rust stdlib actually has std::io::LineWriter which does something similar to what MappedWrite does.
MappedWrite
currently manually appends a single element at a time to its buffer in itsio::Write
implementation (rather than a split and push several at once approach, or similar): https://github.com/heroku/libcnb.rs/blob/fbf391909cc0eacdad459654b5afe99e6a0fd3c1/libherokubuildpack/src/write.rs#L107-L114This seems suboptimal from a performance point of view (given
MappedWrite
's primary use-case is to process the stdout of a process, which could be large in volume).I happened to spot that the Rust stdlib actually has
std::io::LineWriter
which does something similar to whatMappedWrite
does.Whilst we can't use
LineWriter
for our use-case (since it doesn't support a way to map the lines), it's possible we could take inspiration from its implementation: https://github.com/rust-lang/rust/blob/master/library/std/src/io/buffered/linewriter.rs https://github.com/rust-lang/rust/blob/master/library/std/src/io/buffered/linewritershim.rs