Skip to content

Commit

Permalink
internal/lsp/cache: use a map to track package paths to reload
Browse files Browse the repository at this point in the history
I could've sworn I'd already submitted this CL earlier. We've been
sending duplicate package paths to go/packages for no reason.

Updates golang/go#40690

Change-Id: I4c0d082a71e53df12991341b015e0ce8f504c318
Reviewed-on: https://go-review.googlesource.com/c/tools/+/248403
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
  • Loading branch information
stamblerre committed Aug 14, 2020
1 parent cd23824 commit c4923e6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions internal/lsp/cache/snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -696,21 +696,25 @@ func (s *snapshot) reloadWorkspace(ctx context.Context) error {

// See which of the workspace packages are missing metadata.
s.mu.Lock()
var pkgPaths []interface{}
pkgPathSet := map[packagePath]struct{}{}
for id, pkgPath := range s.workspacePackages {
// Don't try to reload "command-line-arguments" directly.
if pkgPath == "command-line-arguments" {
continue
}
if s.metadata[id] == nil {
pkgPaths = append(pkgPaths, pkgPath)
pkgPathSet[pkgPath] = struct{}{}
}
}
s.mu.Unlock()

if len(pkgPaths) == 0 {
if len(pkgPathSet) == 0 {
return nil
}
var pkgPaths []interface{}
for pkgPath := range pkgPathSet {
pkgPaths = append(pkgPaths, pkgPath)
}
return s.load(ctx, pkgPaths...)
}

Expand Down

0 comments on commit c4923e6

Please sign in to comment.