go/gopls/internal
Alan Donovan 63dfc2d3a9 internal/lsp/cache: two minor optimizations
1. Avoid unnecessary intermediate map updates.
2. Avoid accumulating defers in a loop when the control is simple.

Yield: -10% CPU, -37% allocs.

Typical results:

$ go test -v ./gopls/internal/regtest/bench -run=TestBenchmarkDidChange -didchange_dir=$HOME/w/kubernetes -didchange_file=pkg/util/hash/hash.go
Before:
BenchmarkStatistics	     100	  25932206 ns/op	11684109 B/op	   75458 allocs/op
After:
BenchmarkStatistics	     100	  23294195 ns/op	11293472 B/op	   47299 allocs/op

Also, move profiling logic outside the loop so that later runs
don't overwrite earlier runs. (This doesn't appear to be a problem
in practice, presumably because the last run is the big one.)

Updates golang/go#45686

Change-Id: I538ca6bb88cc18f1eefe35d2db29a62e5190280e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/410697
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 21:20:40 +00:00
..
coverage gopls/internal/coverage: apply gofmt to the build tag syntax 2021-04-08 20:55:59 +00:00
govulncheck gopls/internal/vulncheck: use internal/govulncheck 2022-05-31 21:46:24 +00:00
hooks gopls: upgrade staticcheck to v0.3.0 2022-04-07 14:59:24 +00:00
regtest internal/lsp/cache: two minor optimizations 2022-06-06 21:20:40 +00:00
vulncheck gopls/internal/vulncheck: use internal/govulncheck 2022-05-31 21:46:24 +00:00