Skip to content

Commit 8bdde6d

Browse files
committed
internal/lsp: create new cache for each analysis
Because diagnostics computations happen in parallel, we were getting concurrent map writes by keeping one cache. Change-Id: Ifa5adffe14c509168c9f8c5cb012f3fcd3a32441 Reviewed-on: https://go-review.googlesource.com/c/163161 Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
1 parent 191e9ce commit 8bdde6d

File tree

2 files changed

+1
-7
lines changed

2 files changed

+1
-7
lines changed

internal/lsp/cache/view.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,7 @@ func (v *View) FileSet() *token.FileSet {
4646
}
4747

4848
func (v *View) GetAnalysisCache() *source.AnalysisCache {
49-
if v.analysisCache == nil {
50-
v.analysisCache = source.NewAnalysisCache()
51-
}
49+
v.analysisCache = source.NewAnalysisCache()
5250
return v.analysisCache
5351
}
5452

internal/lsp/source/analysis.go

-4
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ type analysisKey struct {
4040
func (c *AnalysisCache) analyze(pkgs []*packages.Package, analyzers []*analysis.Analyzer) []*action {
4141
// TODO(matloob): Every time but the first, this needs to re-construct
4242
// the invalidated parts of the action graph, probably under a lock?
43-
// We'll take care of that later. For now, clear the entire cache!
44-
for k := range c.m {
45-
delete(c.m, k)
46-
}
4743

4844
// Construct the action graph.
4945
var mkAction func(a *analysis.Analyzer, pkg *packages.Package) *action

0 commit comments

Comments
 (0)