Skip to content

Commit

Permalink
Reduce performance impact of result scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
firelizzard18 committed Jun 13, 2021
1 parent b223e48 commit 45b5176
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion interp/interp.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,9 @@ func getFileResult(n *node) *FileResult {
n.Walk(func(n *node) bool {
var sres FileStatementResult
switch n.kind {
case fileStmt, importDecl, typeDecl:
return true

case importSpec:
if len(n.child) == 2 {
sres = &PackageImportResult{
Expand All @@ -506,11 +509,13 @@ func getFileResult(n *node) *FileResult {
sres = &FunctionDeclarationResult{Name: n.child[1].ident}
case typeSpec:
sres = &TypeDeclarationResult{Name: n.child[0].ident}
default:
return false
}
if sres != nil {
res.Statements = append(res.Statements, sres)
}
return true
return false
}, nil)

return res
Expand Down

0 comments on commit 45b5176

Please sign in to comment.