Skip to content

Commit

Permalink
internal/lsp/cache: don't trim types.Info with staticcheck enabled
Browse files Browse the repository at this point in the history
As predicted in CL 308730, there are some analyzers that need this: all
of staticcheck. (I probably should've seen that coming.) For now, don't
do the trimming when staticcheck is on. Since staticcheck ~doubles
memory footprint, those users probably don't care much.

Change-Id: I7cfd96b3654e3617d28d62015928a45a85407d13
Reviewed-on: https://go-review.googlesource.com/c/tools/+/311376
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
  • Loading branch information
heschi committed Apr 19, 2021
1 parent 07295ca commit 1dce19d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/lsp/cache/check.go
Expand Up @@ -454,7 +454,11 @@ func typeCheck(ctx context.Context, snapshot *snapshot, m *metadata, mode source
return nil, ctx.Err()
}

trimTypesInfo(files, pkg.typesInfo)
// staticcheck requires full type information. Reduce memory usage for
// everyone else.
if !snapshot.view.Options().Staticcheck {
trimTypesInfo(files, pkg.typesInfo)
}

// We don't care about a package's errors unless we have parsed it in full.
if mode != source.ParseFull {
Expand Down

0 comments on commit 1dce19d

Please sign in to comment.