Skip to content

Commit a1532b8

Browse files
smasher164stamblerre
authored andcommitted
internal/lsp/cache: avoid string(int) conversion
LoadMode and ParseMode are currently hashed with a string(int) conversion, but this conversion is now discouraged (see the vet check 'stringintconv' for more information). Since the hash uses the code point, this change replaces these instances with string(rune(int)). Updates golang/go#32479. Change-Id: I0d8e91d073fc34ac9faafe75a0d86cf71a5327d4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/232679 Reviewed-by: Rebecca Stambler <[email protected]> Run-TryBot: Rebecca Stambler <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent be0c89d commit a1532b8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

internal/lsp/cache/check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func hashConfig(config *packages.Config) string {
170170

171171
// Dir, Mode, Env, BuildFlags are the parts of the config that can change.
172172
b.WriteString(config.Dir)
173-
b.WriteString(string(config.Mode))
173+
b.WriteString(string(rune(config.Mode)))
174174

175175
for _, e := range config.Env {
176176
b.WriteString(e)

internal/lsp/cache/parse.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (pgh *parseGoHandle) Cached() (*ast.File, []byte, *protocol.ColumnMapper, e
111111
func hashParseKey(ph source.ParseGoHandle) string {
112112
b := bytes.NewBuffer(nil)
113113
b.WriteString(ph.File().Identity().String())
114-
b.WriteString(string(ph.Mode()))
114+
b.WriteString(string(rune(ph.Mode())))
115115
return hashContents(b.Bytes())
116116
}
117117

0 commit comments

Comments
 (0)