1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00
This commit is contained in:
Tao Wen
2018-02-24 22:04:41 +08:00
parent 8d6662b81b
commit fff342fd04
72 changed files with 165 additions and 176 deletions

View File

@ -17,16 +17,16 @@ func init() {
func writeFirstBuf(space []byte, v uint32) []byte {
start := v >> 24
if start == 0 {
space = append(space, byte(v >> 16), byte(v >> 8))
space = append(space, byte(v>>16), byte(v>>8))
} else if start == 1 {
space = append(space, byte(v >> 8))
space = append(space, byte(v>>8))
}
space = append(space, byte(v))
return space
}
func writeBuf(buf []byte, v uint32) []byte {
return append(buf, byte(v >> 16), byte(v >> 8), byte(v))
return append(buf, byte(v>>16), byte(v>>8), byte(v))
}
// WriteUint8 write uint8 to stream
@ -91,7 +91,7 @@ func (stream *Stream) WriteUint32(val uint32) {
stream.buf = writeFirstBuf(stream.buf, digits[q2])
} else {
r3 := q2 - q3*1000
stream.buf = append(stream.buf, byte(q3 + '0'))
stream.buf = append(stream.buf, byte(q3+'0'))
stream.buf = writeBuf(stream.buf, digits[r3])
}
stream.buf = writeBuf(stream.buf, digits[r2])