Refactor: Make a literal/constant tokens map
filhodanuvem opened this issue · comments
Claudson Oliveira commented
In the lexical package we do
func allocMapTokenNames() {
if len(tokenNameMap) == 0 {
tokenNameMap = map[uint8]string{
T_SELECT: "T_SELECT",
T_DISTINCT: "T_DISTINCT",
// ... other tokens
T_USE: "T_USE",
}
}
}
but this could be avoided with a literal/constant map, we don't need an allocMapTokenNames
function. That's a C way of coding that I introduced in the beginning of the project :)
https://github.com/filhodanuvem/gitql/blob/main/lexical/tokens.go
Will Madison commented
I'd be happy to refactor this.
Claudson Oliveira commented
Just go for it @willmadison