mirror of
https://github.com/golang/go
synced 2024-11-05 17:26:11 -07:00
internal/lsp/cache: fix excessive recursion in (*snapshot).clone()
It wasn't infinite, but gopls would sit at 100% cpu for ~25 seconds whenever I made a change to a package imported by essentially everything in my project. Change-Id: Ifa253a4de06897260e0791888284527258e8de48 Reviewed-on: https://go-review.googlesource.com/c/tools/+/212000 Run-TryBot: Muir Manders <muir@mnd.rs> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
84f0c7cf60
commit
979b82bfef
4
internal/lsp/cache/snapshot.go
vendored
4
internal/lsp/cache/snapshot.go
vendored
@ -516,6 +516,10 @@ func (s *snapshot) clone(ctx context.Context, withoutFile source.File) *snapshot
|
||||
transitiveIDs := make(map[packageID]struct{})
|
||||
var addRevDeps func(packageID)
|
||||
addRevDeps = func(id packageID) {
|
||||
if _, seen := transitiveIDs[id]; seen {
|
||||
return
|
||||
}
|
||||
|
||||
transitiveIDs[id] = struct{}{}
|
||||
for _, rid := range s.getImportedByLocked(id) {
|
||||
addRevDeps(rid)
|
||||
|
Loading…
Reference in New Issue
Block a user