philhofer/msgp — pull request #28 by philhofer (2014-11-09 22:42:32+00:00)
Title: Custom reader

This changes the buffering used in `*msgp.Reader` from `*bufio.Reader` to [`*fwd.Reader`](http://github.com/philhofer/fwd).

First of all, this allows reading methods (`m.ReadString()`, `m.ReadFloat64()`, etc.) to *not* mutate the underlying reader if there is a type error. In other words, you can call a bunch of bad methods and still retrieve useful information out of the reader. Before, this was not the case; if there was an unmarshal error in the middle of decoding an object, the stream was partially-read and more-or-less unusable.

Additionally, we get a ~15% speed-up in the average `DecodeMsg` implementation, because we are able to do one fewer data copy. `r.Skip()` is significantly faster, because it uses the `(*fwd.Reader).Skip()` method. (Before, there was no performant way of draining an arbitrary number of bytes from the reader without doing unnecessary copying and allocation.)