Skip to content

Commit

Permalink
internal/lsp/cache: remove unsynchronized write to snapshot.files
Browse files Browse the repository at this point in the history
snapshot.GetVersionedFile already memoizes the file handle in
snapshot.files. There is no reason to do another write, and this write
is unsynchronized.

Fixes golang/go#50747

Change-Id: Ib196395135de6f22dd59169accb756665ad10e58
Reviewed-on: https://go-review.googlesource.com/c/tools/+/380214
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
findleyr committed Jan 21, 2022
1 parent 3425967 commit e7c9de2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internal/lsp/cache/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,11 +396,10 @@ func (s *snapshot) locateTemplateFiles(ctx context.Context) {
excluded := pathExcludedByFilter(relpath, dir, s.view.gomodcache, s.view.options)
if fileHasExtension(path, suffixes) && !excluded && !fi.IsDir() {
k := span.URIFromPath(path)
fh, err := s.GetVersionedFile(ctx, k)
_, err := s.GetVersionedFile(ctx, k)
if err != nil {
return nil
}
s.files[k] = fh
}
searched++
if fileLimit > 0 && searched > fileLimit {
Expand Down

0 comments on commit e7c9de2

Please sign in to comment.