Skip to content

Commit

Permalink
internal/lsp/cache: delete checkSnapshotLocked
Browse files Browse the repository at this point in the history
Now that the entire metadata graph and workspace packages are derived
from metadata, there should be no need to validate coherency.

This results in a small improvement to didChange benchmarking (within
statistical noise).

For golang/go#45686

Change-Id: I32683e025f42d768d62864683e55d4c00146a31c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/340855
TryBot-Result: Gopher Robot <[email protected]>
gopls-CI: kokoro <[email protected]>
Reviewed-by: Alan Donovan <[email protected]>
Run-TryBot: Robert Findley <[email protected]>
  • Loading branch information
findleyr committed Jun 16, 2022
1 parent 567c98b commit c353b05
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions internal/lsp/cache/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/gocommand"
"golang.org/x/tools/internal/lsp/bug"
"golang.org/x/tools/internal/lsp/debug/log"
"golang.org/x/tools/internal/lsp/debug/tag"
"golang.org/x/tools/internal/lsp/source"
"golang.org/x/tools/internal/memoize"
Expand Down Expand Up @@ -1638,29 +1637,6 @@ func generationName(v *View, snapshotID uint64) string {
return fmt.Sprintf("v%v/%v", v.id, snapshotID)
}

// checkSnapshotLocked verifies that some invariants are preserved on the
// snapshot.
func checkSnapshotLocked(ctx context.Context, s *snapshot) {
// Check that every go file for a workspace package is identified as
// belonging to that workspace package.
for wsID := range s.workspacePackages {
if m, ok := s.meta.metadata[wsID]; ok {
for _, uri := range m.GoFiles {
found := false
for _, id := range s.meta.ids[uri] {
if id == wsID {
found = true
break
}
}
if !found {
log.Error.Logf(ctx, "workspace package %v not associated with %v", wsID, uri)
}
}
}
}
}

// unappliedChanges is a file source that handles an uncloned snapshot.
type unappliedChanges struct {
originalSnapshot *snapshot
Expand All @@ -1684,8 +1660,6 @@ func (s *snapshot) clone(ctx, bgCtx context.Context, changes map[span.URI]*fileC
s.mu.Lock()
defer s.mu.Unlock()

checkSnapshotLocked(ctx, s)

newGen := s.view.session.cache.store.Generation(generationName(s.view, s.id+1))
bgCtx, cancel := context.WithCancel(bgCtx)
result := &snapshot{
Expand Down

0 comments on commit c353b05

Please sign in to comment.