diff --git a/encoder.go b/encoder.go index 644d706c..6715eb51 100644 --- a/encoder.go +++ b/encoder.go @@ -42,9 +42,7 @@ func EncodeVarint(w io.Writer, i int64) (err error) { } func VarintSize(i int64) int { - var buf [10]byte - n := binary.PutVarint(buf[:], i) - return n + return UvarintSize(uint64((uint64(i) << 1) ^ uint64(i>>63))) } //----------------------------------------