These functions must create a small byte buffer
and then call w.Write(buf). Since nothing can be
assumed about the behavior of an arbitrary io.Writer,
this buffer is always going to be allocated.
Thus, this API is not possible to make efficient.
I suggest deleting it. It is unused except in tests.
Callers can instead use PutVarint on their own buffer
and then call w.Write. There is no need for a gofix.
ReadUvarint and ReadVarint are also unused except
in tests but they are efficient and provide functionality
that cannot be simulated in other ways, because they
take care to read as few bytes as possible to return an
answer. I believe they should stay.
The text was updated successfully, but these errors were encountered:
Fine w/ me but it does introduce an odd asymmetry. I can think of plenty of situations
where an application doesn't care about maximum performance and thus a WriteXvarint call
is fine. In those cases, a client will simply re-implement the same functionality and
nothing has been won.
Alternatively, I suggest an appropriate comment in the documentation.