mirror of https://github.com/golang/go.git
internal/lsp/cache: don't prune unreachable metadata on clone
Package metadata is small; there is no reason not to keep it around, and pruning it on every clone is needless work. Change-Id: I9ea73315cc6b673625f0f7defe1fd61c2e1eb123 Reviewed-on: https://go-review.googlesource.com/c/tools/+/373695 Reviewed-by: Alan Donovan <adonovan@google.com> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
a2de63544e
commit
4e231cb6f8
|
|
@ -1945,27 +1945,6 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
|
|||
}
|
||||
}
|
||||
|
||||
// Collect all of the IDs that are reachable from the workspace packages.
|
||||
// Any unreachable IDs will have their metadata deleted outright.
|
||||
reachableID := map[PackageID]bool{}
|
||||
var addForwardDeps func(PackageID)
|
||||
addForwardDeps = func(id PackageID) {
|
||||
if reachableID[id] {
|
||||
return
|
||||
}
|
||||
reachableID[id] = true
|
||||
m, ok := s.meta.metadata[id]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for _, depID := range m.Deps {
|
||||
addForwardDeps(depID)
|
||||
}
|
||||
}
|
||||
for id := range s.workspacePackages {
|
||||
addForwardDeps(id)
|
||||
}
|
||||
|
||||
// Compute which metadata updates are required. We only need to invalidate
|
||||
// packages directly containing the affected file, and only if it changed in
|
||||
// a relevant way.
|
||||
|
|
@ -1977,12 +1956,6 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
|
|||
metadataUpdates[k] = nil
|
||||
continue
|
||||
}
|
||||
// The ID is not reachable from any workspace package, so it should
|
||||
// be deleted.
|
||||
if !reachableID[k] {
|
||||
metadataUpdates[k] = nil
|
||||
continue
|
||||
}
|
||||
valid := v.Valid && !invalidateMetadata
|
||||
pkgFilesChanged := v.PkgFilesChanged || changedPkgFiles[k]
|
||||
shouldLoad := v.ShouldLoad || invalidateMetadata
|
||||
|
|
|
|||
Loading…
Reference in New Issue