Thanks to visit codestin.com
Credit goes to github.com

Skip to content

flate.Reader and double buffering #130

@rdmrcv

Description

@rdmrcv

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions