Merge pull request #637 from nspcc-dev/feature/optimize_constants

compiler: do not store constants as variables
This commit is contained in:
Roman Khimov 2020-02-03 14:59:06 +03:00 committed by GitHub
commit f69d317036
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -138,7 +138,11 @@ func (c *codegen) convertGlobals(f ast.Node) {
case *ast.FuncDecl: case *ast.FuncDecl:
return false return false
case *ast.GenDecl: case *ast.GenDecl:
ast.Walk(c, n) // constants are loaded directly so there is no need
// to store them as a local variables
if n.Tok != token.CONST {
ast.Walk(c, n)
}
} }
return true return true
}) })