Skip to content

Commit

Permalink
Revert encoding change
Browse files Browse the repository at this point in the history
  • Loading branch information
yolken-segment committed Nov 23, 2020
1 parent c1c8237 commit e048356
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion protocol/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,22 @@ func (e *encoder) writeCompactNullBytesFrom(b Bytes) error {
}

func (e *encoder) writeVarInt(i int64) {
e.writeUnsignedVarInt(uint64((i << 1) ^ (i >> 63)))
b := e.buffer[:]
u := uint64((i << 1) ^ (i >> 63))
n := 0

for u >= 0x80 && n < len(b) {
b[n] = byte(u) | 0x80
u >>= 7
n++
}

if n < len(b) {
b[n] = byte(u)
n++
}

e.Write(b[:n])
}

func (e *encoder) writeUnsignedVarInt(i uint64) {
Expand Down

0 comments on commit e048356

Please sign in to comment.