Skip to content

Make default int encoding varint (not zigzag)#238

Merged
liamsi merged 11 commits intodevelopfrom
default_int_encoding
Oct 26, 2018
Merged

Make default int encoding varint (not zigzag)#238
liamsi merged 11 commits intodevelopfrom
default_int_encoding

Conversation

@liamsi
Copy link
Copy Markdown
Contributor

@liamsi liamsi commented Oct 25, 2018

First stab on #237
related to tendermint/tendermint#2682

I propose to do a followup PR to add back the zigzag encoding option (via a tag).

@liamsi liamsi changed the title WIP: Make default int encoding varint (not zigzag) Make default int encoding varint (not zigzag) Oct 25, 2018
Comment thread binary-decode.go Outdated
return
}
rv.SetInt(num)
rv.SetInt(int64(unum))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also check that unum <= math.MaxInt64 ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Yes, you are right, we should!

Copy link
Copy Markdown
Contributor Author

@liamsi liamsi Oct 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh actually, this wouldn't make any sense in this case. Any negative value num will certainly be > math.MaxInt64 (all negative nums get encoded "after" MaxInt64). But checks make sense in the cases of int32 (and depending on the platform, also for int). I'll add those.

Comment thread binary-decode.go Outdated
rv.SetInt(num)
} else {
num, _n, err = DecodeVarint(bz)
var unum uint64
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be called a unum. Unums are a cool proposal to replace floats. https://en.wikipedia.org/wiki/Unum_(number_format).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Universal numbers ... Thanks! Learned something new. I'll rename to u64 or sth like this.

@liamsi
Copy link
Copy Markdown
Contributor Author

liamsi commented Oct 26, 2018

Addressed all comments and updated the changelog for another release. Want to have another look? Or good to merge @melekes @ValarDragon

Comment thread binary-decode.go Outdated
// cdc.decodeReflectBinary

var (
ErrOverflowInt = errors.New("encoded integer value value overflows int(32)")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value value

@liamsi liamsi merged commit c28d73b into develop Oct 26, 2018
@liamsi liamsi deleted the default_int_encoding branch October 26, 2018 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants