]> Cypherpunks repositories - gostls13.git/commit
encoding/json: reduce allocations by Decoder for \uXXXX
authorMichael Schurter <michael.schurter@gmail.com>
Sat, 3 Jun 2017 20:36:54 +0000 (13:36 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 22 Nov 2017 03:36:29 +0000 (03:36 +0000)
commit7eb7f8f5a75fcff520b5b93a7831fa7044d86887
tree00ea6c56bd13dc3983ad52658eb42afc72a82935
parent71aee2a190e6a26858b16a0974afdf976f2b0905
encoding/json: reduce allocations by Decoder for \uXXXX

Manually convert hex escape sequence to rune instead of calling
strconv.ParseUint.

This inlines the unhex func from docs (and many other packages).

name              old time/op    new time/op    delta
UnicodeDecoder-4     468ns ± 1%     402ns ± 1%  -14.26%  (p=0.000
n=10+10)

name              old speed      new speed      delta
UnicodeDecoder-4  29.9MB/s ± 1%  34.8MB/s ± 1%  +16.59%  (p=0.000
n=10+10)

name              old alloc/op   new alloc/op   delta
UnicodeDecoder-4     44.0B ± 0%     36.0B ± 0%  -18.18%  (p=0.000
n=10+10)

name              old allocs/op  new allocs/op  delta
UnicodeDecoder-4      4.00 ± 0%      2.00 ± 0%  -50.00%  (p=0.000
n=10+10)

Fixes #20567

Change-Id: If350978d5bb98ff517485752184d02249f5d1f3a
Reviewed-on: https://go-review.googlesource.com/44738
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/encoding/json/bench_test.go
src/encoding/json/decode.go