From 4e231cb6f8b5a782a7973e80dbc8ef7183799dad Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Sun, 15 Aug 2021 12:02:50 -0400 Subject: [PATCH] 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 Run-TryBot: Robert Findley gopls-CI: kokoro TryBot-Result: Gopher Robot --- internal/lsp/cache/snapshot.go | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/internal/lsp/cache/snapshot.go b/internal/lsp/cache/snapshot.go index b85b46c64c..3c46648bff 100644 --- a/internal/lsp/cache/snapshot.go +++ b/internal/lsp/cache/snapshot.go @@ -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