Skip to content

Commit c4923e6

Browse files
committed
internal/lsp/cache: use a map to track package paths to reload
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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]>
1 parent cd23824 commit c4923e6

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

internal/lsp/cache/snapshot.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,21 +696,25 @@ func (s *snapshot) reloadWorkspace(ctx context.Context) error {
696696

697697
// See which of the workspace packages are missing metadata.
698698
s.mu.Lock()
699-
var pkgPaths []interface{}
699+
pkgPathSet := map[packagePath]struct{}{}
700700
for id, pkgPath := range s.workspacePackages {
701701
// Don't try to reload "command-line-arguments" directly.
702702
if pkgPath == "command-line-arguments" {
703703
continue
704704
}
705705
if s.metadata[id] == nil {
706-
pkgPaths = append(pkgPaths, pkgPath)
706+
pkgPathSet[pkgPath] = struct{}{}
707707
}
708708
}
709709
s.mu.Unlock()
710710

711-
if len(pkgPaths) == 0 {
711+
if len(pkgPathSet) == 0 {
712712
return nil
713713
}
714+
var pkgPaths []interface{}
715+
for pkgPath := range pkgPathSet {
716+
pkgPaths = append(pkgPaths, pkgPath)
717+
}
714718
return s.load(ctx, pkgPaths...)
715719
}
716720

0 commit comments

Comments
 (0)