Closed chris-zen closed 5 years ago
FWIW, I had a quick look at the changes and except for the one comment I can't see anything blatantly wrong. I remember that I wrote the code in such a way that a PacketBuffer
cannot be empty (and I had a comment in there to indicate this), but it looks like your changes touch all the relevant places where this would make a difference.
@Boddlnagg I appreciate you had a look. I am wondering if this would be good for midir
. The main purpose for me was to allow allocating enough memory for the buffer once at the beginning, and then re-use it without more allocations the rest of the time.
@Boddlnagg FYI I have been using this code for quite some time now and I didn't have any trouble. I'm going to merge and release.
This PR gives a
PacketBuffer
the capability to be empty at any moment, as well as to be created with an specific capacity from the beginning. It also makes some minor refactoring.PacketBuffer
keeps backward compatibility, but introduces new methods:with_capacity(capacity: usize) -> PacketBuffer
capacity(&self) -> usize
clear(&mut self)
@Boddlnagg and @raphlinus I'm pinging you in case you are interested in reviewing.