aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/encode.go
diff options
context:
space:
mode:
authorPhil Pearl <philip.j.r.pearl@gmail.com>2019-10-13 13:01:58 +0100
committerDaniel Martí <mvdan@mvdan.cc>2019-10-27 16:02:29 +0000
commit22d377077c01ced185f5f8d27f608e8c6dcb473c (patch)
tree6e2a7c6470f2991ee2a54dded0dcb165bbf8217a /src/encoding/json/encode.go
parent31bfab4ac621e81100d7fc3bc8cf483c5d2d2fef (diff)
downloadgo-22d377077c01ced185f5f8d27f608e8c6dcb473c.tar.xz
encoding/json: improve performance of Compact
This change improves performance of Compact by using a sync.Pool to allow re-use of a scanner. This also has the side-effect of removing an allocation for each field that implements Marshaler when marshalling JSON. name old time/op new time/op delta EncodeMarshaler-8 118ns ± 2% 104ns ± 1% -12.21% (p=0.001 n=7+7) name old alloc/op new alloc/op delta EncodeMarshaler-8 100B ± 0% 36B ± 0% -64.00% (p=0.000 n=8+8) name old allocs/op new allocs/op delta EncodeMarshaler-8 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=8+8) Change-Id: Ic70c61a0a6354823da5220f5aad04b94c054f233 Reviewed-on: https://go-review.googlesource.com/c/go/+/200864 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/encoding/json/encode.go')
0 files changed, 0 insertions, 0 deletions