Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/binary: delete WriteUvarint and WriteVarint #2748

Closed
rsc opened this issue Jan 20, 2012 · 3 comments
Closed

encoding/binary: delete WriteUvarint and WriteVarint #2748

rsc opened this issue Jan 20, 2012 · 3 comments
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Jan 20, 2012

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.
@griesemer
Copy link
Contributor

Comment 1:

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.

@rsc
Copy link
Contributor Author

rsc commented Jan 20, 2012

Comment 2:

In those cases, the inefficient code is in the client, not in
the standard library.  That's a significant win: it's not our fault.

@griesemer
Copy link
Contributor

Comment 3:

This issue was closed by revision 0796c1c.

Status changed to Fixed.

@rsc rsc added fixed labels Jan 20, 2012
@rsc rsc added this to the Go1 milestone Apr 10, 2015
@rsc rsc removed the priority-go1 label Apr 10, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants