Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(729)

Issue 5146048: code review 5146048: encoding/binary: support for varint encoding (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 5 months ago by gri
Modified:
13 years, 5 months ago
Reviewers:
CC:
rsc, r2, nigeltao, r, dsymonds, golang-dev
Visibility:
Public.

Description

encoding/binary: support for varint encoding

Patch Set 1 #

Patch Set 2 : diff -r c8a7809fabcd https://go.googlecode.com/hg/ #

Patch Set 3 : diff -r c8a7809fabcd https://go.googlecode.com/hg/ #

Patch Set 4 : diff -r c8a7809fabcd https://go.googlecode.com/hg/ #

Patch Set 5 : diff -r c8a7809fabcd https://go.googlecode.com/hg/ #

Patch Set 6 : diff -r c8a7809fabcd https://go.googlecode.com/hg/ #

Total comments: 4

Patch Set 7 : diff -r c8a7809fabcd https://go.googlecode.com/hg/ #

Patch Set 8 : diff -r c8a7809fabcd https://go.googlecode.com/hg/ #

Patch Set 9 : diff -r c8a7809fabcd https://go.googlecode.com/hg/ #

Total comments: 34

Patch Set 10 : diff -r 9a44dedca5dd https://go.googlecode.com/hg/ #

Total comments: 12

Patch Set 11 : diff -r 9a44dedca5dd https://go.googlecode.com/hg/ #

Patch Set 12 : diff -r 9a44dedca5dd https://go.googlecode.com/hg/ #

Total comments: 12

Patch Set 13 : diff -r 7ae32f195afd https://go.googlecode.com/hg/ #

Unified diffs Side-by-side diffs Delta from patch set Stats (+342 lines, -3 lines) Patch
M src/pkg/encoding/binary/Makefile View 1 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/encoding/binary/binary.go View 1 1 chunk +3 lines, -3 lines 0 comments Download
A src/pkg/encoding/binary/varint.go View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +163 lines, -0 lines 0 comments Download
A src/pkg/encoding/binary/varint_test.go View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +175 lines, -0 lines 0 comments Download

Messages

Total messages: 18
gri
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://go.googlecode.com/hg/
13 years, 5 months ago (2011-09-28 01:12:45 UTC) #1
rsc
http://codereview.appspot.com/5146048/diff/10001/src/pkg/encoding/binary/varint.go File src/pkg/encoding/binary/varint.go (right): http://codereview.appspot.com/5146048/diff/10001/src/pkg/encoding/binary/varint.go#newcode19 src/pkg/encoding/binary/varint.go:19: // PutUint encodes a uint64 into buf and returns ...
13 years, 5 months ago (2011-09-28 01:28:21 UTC) #2
gri
PTAL. I also changed error handling a bit: - to be compatible with longer encodings ...
13 years, 5 months ago (2011-09-28 02:55:53 UTC) #3
r2
the U is in the wrong place but it looks truly horrible in the right ...
13 years, 5 months ago (2011-09-28 04:05:27 UTC) #4
nigeltao
I'd also add // MaxVarintLen is the maximum length of a varint-encoded int64 or uint64. ...
13 years, 5 months ago (2011-09-28 10:09:03 UTC) #5
r
http://codereview.appspot.com/5146048/diff/2010/src/pkg/encoding/binary/varint.go File src/pkg/encoding/binary/varint.go (right): http://codereview.appspot.com/5146048/diff/2010/src/pkg/encoding/binary/varint.go#newcode6 src/pkg/encoding/binary/varint.go:6: // The encoding is as follows: The encoding is: ...
13 years, 5 months ago (2011-09-28 16:10:09 UTC) #6
gri
PTAL. Also: added missing tests. http://codereview.appspot.com/5146048/diff/2010/src/pkg/encoding/binary/varint.go File src/pkg/encoding/binary/varint.go (right): http://codereview.appspot.com/5146048/diff/2010/src/pkg/encoding/binary/varint.go#newcode5 src/pkg/encoding/binary/varint.go:5: // This file implements ...
13 years, 5 months ago (2011-09-28 18:26:24 UTC) #7
r
http://codereview.appspot.com/5146048/diff/14007/src/pkg/encoding/binary/varint.go File src/pkg/encoding/binary/varint.go (right): http://codereview.appspot.com/5146048/diff/14007/src/pkg/encoding/binary/varint.go#newcode15 src/pkg/encoding/binary/varint.go:15: // are written as 2*(^x) + 1; i.e., negative ...
13 years, 5 months ago (2011-09-28 18:33:48 UTC) #8
gri
PTAL http://codereview.appspot.com/5146048/diff/14007/src/pkg/encoding/binary/varint.go File src/pkg/encoding/binary/varint.go (right): http://codereview.appspot.com/5146048/diff/14007/src/pkg/encoding/binary/varint.go#newcode15 src/pkg/encoding/binary/varint.go:15: // are written as 2*(^x) + 1; i.e., ...
13 years, 5 months ago (2011-09-28 19:56:36 UTC) #9
r
LGTM anyone else?
13 years, 5 months ago (2011-09-29 00:21:37 UTC) #10
rsc
LGTM I only looked at the API.
13 years, 5 months ago (2011-09-29 00:22:24 UTC) #11
dsymonds
LGTM http://codereview.appspot.com/5146048/diff/22001/src/pkg/encoding/binary/varint.go File src/pkg/encoding/binary/varint.go (right): http://codereview.appspot.com/5146048/diff/22001/src/pkg/encoding/binary/varint.go#newcode7 src/pkg/encoding/binary/varint.go:7: // This file implements "varint" encoding of 64bit ...
13 years, 5 months ago (2011-09-29 00:32:14 UTC) #12
dsymonds
LGTM Also, the test only checks round trips, but it would be good to have ...
13 years, 5 months ago (2011-09-29 00:36:57 UTC) #13
gri
http://codereview.appspot.com/5146048/diff/22001/src/pkg/encoding/binary/varint.go File src/pkg/encoding/binary/varint.go (right): http://codereview.appspot.com/5146048/diff/22001/src/pkg/encoding/binary/varint.go#newcode7 src/pkg/encoding/binary/varint.go:7: // This file implements "varint" encoding of 64bit integers. ...
13 years, 5 months ago (2011-09-29 05:35:04 UTC) #14
gri
*** Submitted as http://code.google.com/p/go/source/detail?r=39de8f482ea8 *** encoding/binary: support for varint encoding R=rsc, r, nigeltao, r, dsymonds ...
13 years, 5 months ago (2011-09-29 05:36:56 UTC) #15
rsc
I don't remember seeing this detail of the API when I looked. Maybe I just ...
13 years, 5 months ago (2011-09-29 13:42:45 UTC) #16
rsc
If the max is not enough, a separate func VarintSize(x int64) int and UvarintSize(x uint64) ...
13 years, 5 months ago (2011-09-29 13:59:26 UTC) #17
gri
13 years, 5 months ago (2011-09-29 16:28:03 UTC) #18
There was always an error return (0) if the buffer was too small, in
consistency with the read routines. In a second step I added the
negative length because the read routines also return the negative
length in error cases (overflow). It doesn't cost when not used. I was
contemplating just crashing, but the implementation made the error
return free.

Anyway, simplified, as consistency w/ EncodeRune is compelling. See CL 5163041.
- gri

On Thu, Sep 29, 2011 at 6:59 AM, Russ Cox <rsc@golang.org> wrote:
> If the max is not enough, a separate func VarintSize(x int64) int
> and UvarintSize(x uint64) int would be fine too and
> would still avoid needing to overload the return value.
>
> Russ
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b