]> Cypherpunks repositories - gostls13.git/commit
encoding/json: simplify some pieces of the encoder
authorDaniel Martí <mvdan@mvdan.cc>
Sat, 7 Jul 2018 18:07:14 +0000 (19:07 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Wed, 22 Aug 2018 16:14:05 +0000 (16:14 +0000)
commit9d1540b77c3965f1cbaaab753d09974ad7330380
treeaa1af876f4e666114d999725503a8adaa151c718
parent841a9136b3d737d1252f7c5c371f109f23d76b2d
encoding/json: simplify some pieces of the encoder

Some WriteByte('\\') calls can be deduplicated.

fillField is used in two occasions, but it is unnecessary when adding
fields to the "next" stack, as those aren't used for the final encoding.
Inline the func with its only remaining call.

Finally, unindent a default-if block.

The performance of the encoder is unaffected:

name           old time/op    new time/op    delta
CodeEncoder-4    6.65ms ± 1%    6.65ms ± 0%   ~     (p=0.662 n=6+5)

Change-Id: Ie55baeab89abad9b9f13e9f6ca886a670c30dba9
Reviewed-on: https://go-review.googlesource.com/122461
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/encoding/json/encode.go