encoding/json: allocate less in NewEncoder
The *Encoder is almost always garbage. It doesn't need an encodeState inside of it (and its bytes.Buffer), since it's only needed locally inside of Encode. benchmark old ns/op new ns/op delta BenchmarkEncoderEncode 2562 2553 -0.35% benchmark old bytes new bytes delta BenchmarkEncoderEncode 283 102 -63.96% R=r CC=gobot, golang-dev https://golang.org/cl/9365044
Showing
Please
register
or
sign in
to comment