Skip to content

design questions #1

Description

@BurntSushi

I just came across your library, and I'm curious about the rationale for the current implementation. In particular, it looks like encoding a varint requires an allocation (specifically, a VecDeque). This seems very heavyweight.

The README mentions that this doesn't implement methods for writing to a stream/buffer, but it seems to me that methods for writing to a stream/buffer are actually much more fundamental than requiring an allocation.

For inspiration, I'd suggest looking at Go's standard library encoding/binary package. Half of it is for writing fixed size numbers, but the other half is for variable integer decoding. I'd expect a Rust API to look pretty similar: http://golang.org/pkg/encoding/binary/

The key is that a "buffer" can actually be stack allocated, so it allows the caller a lot more freedom.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions