]> Cypherpunks repositories - gostls13.git/commit
encoding/json: speed up decoding
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 18 Dec 2013 15:30:21 +0000 (07:30 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 18 Dec 2013 15:30:21 +0000 (07:30 -0800)
commit626da8d73741b0cdeaa1acc048fec9ec8286f2b5
treecdb8306b9aeca1634f1050fff67d710e4af5dcb3
parent5334b73d5d57aee6948897fa4b1bfafe5bb70c6f
encoding/json: speed up decoding

Don't make copies of keys while decoding, and don't use the
expensive strings.EqualFold when it's not necessary. Instead,
note in the existing field cache what algorithm to use to
check fold equality... most keys are just ASCII letters.

benchmark               old ns/op    new ns/op    delta
BenchmarkCodeDecoder    137074314    103974418  -24.15%

benchmark                old MB/s     new MB/s  speedup
BenchmarkCodeDecoder        14.16        18.66    1.32x

Update #6496

R=golang-dev, rsc, adg, r, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/13894045
src/pkg/encoding/json/decode.go
src/pkg/encoding/json/encode.go
src/pkg/encoding/json/fold.go [new file with mode: 0644]
src/pkg/encoding/json/fold_test.go [new file with mode: 0644]