-
Notifications
You must be signed in to change notification settings - Fork 59
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
Fix varint
marshal, unmarshall
#309
base: master
Are you sure you want to change the base?
Conversation
3ee15a2
to
6b215f1
Compare
switch { | ||
case byte(v>>63) != 0: | ||
return []byte{0, byte(v >> 56), byte(v >> 48), byte(v >> 40), byte(v >> 32), byte(v >> 24), byte(v >> 16), byte(v >> 8), byte(v)} | ||
case byte(v>>55) != 0: | ||
return []byte{byte(v >> 56), byte(v >> 48), byte(v >> 40), byte(v >> 32), byte(v >> 24), byte(v >> 16), byte(v >> 8), byte(v)} | ||
case byte(v>>47) != 0: | ||
return []byte{byte(v >> 48), byte(v >> 40), byte(v >> 32), byte(v >> 24), byte(v >> 16), byte(v >> 8), byte(v)} | ||
case byte(v>>39) != 0: | ||
return []byte{byte(v >> 40), byte(v >> 32), byte(v >> 24), byte(v >> 16), byte(v >> 8), byte(v)} | ||
case byte(v>>31) != 0: | ||
return []byte{byte(v >> 32), byte(v >> 24), byte(v >> 16), byte(v >> 8), byte(v)} | ||
case byte(v>>23) != 0: | ||
return []byte{byte(v >> 24), byte(v >> 16), byte(v >> 8), byte(v)} | ||
case byte(v>>15) != 0: | ||
return []byte{byte(v >> 16), byte(v >> 8), byte(v)} | ||
case byte(v>>7) != 0: | ||
return []byte{byte(v >> 8), byte(v)} | ||
default: | ||
return []byte{byte(v)} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why encUint64
and encUint
are the same ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint
max bit size same as uint64
for 64-bit architectures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exactly, why not to use same function ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are inputs are different uint
and uint64
.
I don`t want to use unnecessary type convert.
12557fa
to
b063b8e
Compare
b063b8e
to
6edc349
Compare
6edc349
to
9a66efd
Compare
Fixed for
varint
type:string
marshal and unmarshal asnullable
.1.1. Before: marshals
""
- caused an error; unmarshalsnil data
into"0"
.1.2. Now: marshals and unmarshals
nil data
-""
.string
(bigger thenmath.MaxInt64
) marshal and unmarshal, beforenot supported
, nowsupported
.custom string
unmarshals, beforenot supported
, nowsupported
.go types
marshals and unmarshal functions are optimized.math.MaxUint64
, intouint64
,uint
, returnerror
before, nowno error
.