Commit 91a48115 authored by Robert Griesemer's avatar Robert Griesemer

gob: slightly simpler code for encodeUint

R=r
CC=golang-dev
https://golang.org/cl/5077047
parent d16ceca5
...@@ -59,15 +59,14 @@ func (state *encoderState) encodeUint(x uint64) { ...@@ -59,15 +59,14 @@ func (state *encoderState) encodeUint(x uint64) {
} }
return return
} }
var n, m int i := uint64Size
m = uint64Size for x > 0 {
for n = 1; x > 0; n++ { state.buf[i] = uint8(x)
state.buf[m] = uint8(x)
x >>= 8 x >>= 8
m-- i--
} }
state.buf[m] = uint8(-(n - 1)) state.buf[i] = uint8(i - uint64Size) // = loop count, negated
n, err := state.b.Write(state.buf[m : uint64Size+1]) _, err := state.b.Write(state.buf[i : uint64Size+1])
if err != nil { if err != nil {
error(err) error(err)
} }
......
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