go/internal/lsp/cache
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
..
analysis.go gopls: remove usage of golang.org/x/xerrors 2022-04-20 15:33:22 +00:00
cache.go internal/template: identify template files by the templateExtensions option 2022-01-13 17:30:17 +00:00
check.go internal/lsp/cache: invalidate metadata when parsing issues resolve 2022-05-23 18:14:40 +00:00
error_test.go internal/lsp/cache: split up sourceDiagnostics 2021-03-02 02:05:13 +00:00
errors.go internal/span: eliminate TokenConverter 2022-06-01 19:19:15 +00:00
imports.go internal/lsp/cache: use -workfile on 1.18 2022-02-04 14:03:59 +00:00
keys.go internal/lsp: decouple client and server debug 2020-06-11 13:49:48 +00:00
load.go internal/lsp/progress: detach context for all progress notifications 2022-06-02 20:26:04 +00:00
metadata.go gopls: wire in LangVersion and ModulePath for gofumpt formatting 2022-02-24 18:08:50 +00:00
mod.go internal/lsp: factor out column mapper construction from content 2022-06-01 19:19:49 +00:00
mod_tidy.go internal/span: eliminate TokenConverter 2022-06-01 19:19:15 +00:00
os_darwin.go internal/lsp/cache: clarify an error message about mismatching casing 2021-08-03 17:18:10 +00:00
os_windows.go internal/lsp/cache: clarify an error message about mismatching casing 2021-08-03 17:18:10 +00:00
parse.go internal/span: eliminate TokenConverter 2022-06-01 19:19:15 +00:00
parse_test.go internal/lsp/cache: trim more stuff in ParseExported mode 2021-05-11 17:48:41 +00:00
parsemode_go116.go internal/lsp/cache: use cached parsed files for symbols, if available 2022-05-09 17:04:06 +00:00
parsemode_go117.go internal/lsp/cache: use cached parsed files for symbols, if available 2022-05-09 17:04:06 +00:00
pkg.go gopls: remove usage of golang.org/x/xerrors 2022-04-20 15:33:22 +00:00
session.go gopls: remove usage of golang.org/x/xerrors 2022-04-20 15:33:22 +00:00
snapshot.go internal/lsp/cache: two minor optimizations 2022-06-06 21:20:40 +00:00
symbols.go internal/lsp/cache: invalidate metadata when parsing issues resolve 2022-05-23 18:14:40 +00:00
view.go gopls: remove usage of golang.org/x/xerrors 2022-04-20 15:33:22 +00:00
view_test.go internal/lsp/cache: always consider go.work files for ws expansion 2022-03-07 16:11:49 +00:00
workspace.go gopls: remove usage of golang.org/x/xerrors 2022-04-20 15:33:22 +00:00
workspace_test.go internal/lsp/cache: construct workspace even when go.work has error 2022-03-03 21:30:30 +00:00