buffered improvements for the reader
Mostly a note to self for next time like I feel like working on this.
Tonight I just modified the WriteChain to write in buffers instead of at every operation. This yielded great performance improvements. Of course, we could do this on Reader as well, except that it wouldn't be backwards compatible, seeing as we don't know beforehand how much data we will need to read.
encoding/binary has an advantage over us, because it knows beforehand how many values it needs to read (it has one function with one array). We, of course, can't do that: the only way to know the amount of stuff to read beforehand is by having a "ReadChain" which holds references to the value to which to decode. And then a whole other bunch of problems come up.
(Ironically, I remember when I started working on binary I intended to have ReadChain, but then discarded the idea)
The encoding/json solution is to buffer the data, but let users have https://golang.org/pkg/encoding/json/#Decoder.Buffered to read from the already-buffered data. Which could be adequate.
A non breaking way could be to have a parameter like Length
in the reader, which basically tells it how much there is still to read. (And could be -1 to always read max buffer). Problem with this, though, is that any if
we add costs time, so if it comes to it we'll just bump a major version.