-
Notifications
You must be signed in to change notification settings - Fork 388
Description
Hello! Thanks for a great lib.
I try to use pre-released wsflate package and see a slight caveat when try to re-use decoders.
As I can see the flate.decompressor (default flate.Reader impl) try to prevent double buffering if it possible and when I call Reset, or NewReader it calls a small func that called makeReader. That func will check if passed io.Reader also implements flate.Reader and can be used as-is without buffering.
If it not - it will allocate bufio.NewReader with defaultBufSize (4kb) slice and wraps passed reader into it.
When I work with byte.Reader on my side — it can rely to that behavior and if I pass bytes.Reader I avoid double buffering (since it already implements flate.Reader). But in wsflate there is suffixReader that wraps passed io.Reader and erase its ReadByte method when Reader.Reset was called.
It might be great to have a way to prevent double buffering here and if I already pass buffered reader here - prevent it from being wrapped in flate.decompressor.