1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

support []byte; marshal without copy

This commit is contained in:
Tao Wen
2017-06-06 09:44:56 +08:00
parent 3979955e69
commit a4e5abf492
9 changed files with 225 additions and 140 deletions

View File

@ -33,9 +33,7 @@ func (stream *Stream) WriteFloat32Lossy(val float32) {
return
}
stream.writeByte('.')
if stream.Available() < 10 {
stream.Flush()
}
stream.ensure(10)
for p := precision - 1; p > 0 && fval < POW10[p]; p-- {
stream.writeByte('0')
}
@ -67,9 +65,7 @@ func (stream *Stream) WriteFloat64Lossy(val float64) {
return
}
stream.writeByte('.')
if stream.Available() < 10 {
stream.Flush()
}
stream.ensure(10)
for p := precision - 1; p > 0 && fval < POW10[p]; p-- {
stream.writeByte('0')
}