mirror of
https://github.com/soheilhy/cmux.git
synced 2026-08-06 15:18:36 +08:00
bufferedReader is an optimized implementation of io.Reader that behaves like ``` io.MultiReader(bytes.NewReader(buffer.Bytes()), io.TeeReader(source, buffer)) ``` without allocating. This has a measurable effect on benchmarks: ``` name old time/op new time/op delta CMuxConn-4 1.09µs ± 4% 0.99µs ±19% -9.32% (p=0.000 n=17+19) name old alloc/op new alloc/op delta CMuxConn-4 240B ± 0% 260B ± 0% +8.33% (p=0.000 n=20+20) name old allocs/op new allocs/op delta CMuxConn-4 9.00 ± 0% 5.00 ± 0% -44.44% (p=0.000 n=20+20) ``` Note that appropriate test coverage is provided by `TestRead`.
867 B
867 B