3 ms·
> But doesn't this make the typical use case (just a few "yes"s needed) slower, since first it has to fill a buffer? One could put a write in the memcpy loop,
by dbaupp 9y ago
> But doesn't this make the typical use case (just a few "yes"s needed) slower, since first it has to fill a buffer?
One could put a write in the memcpy loop, so that first it writes one copy of the string, then two, then 4, 8 (etc.), meaning time to first byte is short, but it quickly gets up to the eventual asymptotic speed with a full buffer.
( https://www.reddit.com/r/rust/comments/4wde08/optimising_yes_any_further_ideas/d663d13/ https://www.reddit.com/r/rust/comments/4wde08/optimising_yes... )
- masklinn 9y agoYou could also have a static buffer full of yesses, it would increase the binary size by 8k, but GNU yes is already 40k on my system so...
- dbaupp 9y agoThat is mentioned elsewhere in this very thread, where it is also pointed out that that isn't a general solution (`yes` can print more than just y).