Skip to content

Commit 0b6d133

Browse files
authored
Use array for tokenToText (#2292)
1 parent 8372401 commit 0b6d133

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

internal/scanner/scanner.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2064,14 +2064,13 @@ func isInUnicodeRanges(cp rune, ranges []rune) bool {
20642064
return false
20652065
}
20662066

2067-
var tokenToText map[ast.Kind]string
2068-
2069-
func init() {
2070-
tokenToText = make(map[ast.Kind]string, len(textToToken))
2071-
for text, key := range textToToken {
2072-
tokenToText[key] = text
2067+
var tokenToText = func() [ast.KindCount]string {
2068+
var result [ast.KindCount]string
2069+
for text, kind := range textToToken {
2070+
result[kind] = text
20732071
}
2074-
}
2072+
return result
2073+
}()
20752074

20762075
func TokenToString(token ast.Kind) string {
20772076
return tokenToText[token]

0 commit comments

Comments
 (0)