Commit 1a8ba091 authored by Cole Brown's avatar Cole Brown

Fix bug in VarintSize

:100644 100644 79ebe2f b0ced77 M	varint.go
parent ec8630b6
......@@ -8,7 +8,13 @@ import (
// VarintSize returns the size (in bytes) of `num` encoded as a varint.
func VarintSize(num int) int {
return bits.Len(uint(num))/7 + 1
bits := bits.Len(uint(num))
q, r := bits/7, bits%7
size := q
if r > 0 {
size++
}
return size
}
// CodeToVarint converts an integer to a varint-encoded []byte
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment