aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/decode.go
diff options
context:
space:
mode:
authorKeith Randall <khr@google.com>2019-04-29 12:19:30 -0700
committerKeith Randall <khr@golang.org>2019-04-29 23:45:15 +0000
commitee59c06acb1cd0a119667fce57988801d3fdde4f (patch)
treed980f0d708fe03f3d52daafd7648627d51c41b01 /src/encoding/json/decode.go
parent998cc2a1c5cad0e928f0ac07f69af36123192460 (diff)
downloadgo-ee59c06acb1cd0a119667fce57988801d3fdde4f.tar.xz
cmd/compile: evaluate map initializers incrementally
For the code: m := map[int]int { a(): b(), c(): d(), e(): f(), } We used to do: t1 := a() t2 := b() t3 := c() t4 := d() t5 := e() t6 := f() m := map[int]int{} m[t1] = t2 m[t3] = t4 m[t5] = t6 After this CL we do: m := map[int]int{} t1 := a() t2 := b() m[t1] = t2 t3 := c() t4 := d() m[t3] = t4 t5 := e() t6 := f() m[t5] = t6 Ordering the initialization this way limits the lifetime of the temporaries involved. In particular, for large maps the number of simultaneously live temporaries goes from ~2*len(m) to ~2. This change makes the compiler (regalloc, mostly) a lot happier. The compiler runs faster and uses a lot less memory. For #26546, changes compile time of a big map from 8 sec to 0.5 sec. Fixes #26552 Update #26546 Change-Id: Ib7d202dead3feaf493a464779fd9611c63fcc25f Reviewed-on: https://go-review.googlesource.com/c/go/+/174417 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/encoding/json/decode.go')
0 files changed, 0 insertions, 0 deletions