Skip to content

Commit 7b348bb

Browse files
committed
fix fast return
1 parent 3e8fccf commit 7b348bb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

exportloopref.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type Searcher struct {
5353
Pass *analysis.Pass
5454
}
5555

56-
// CheckAndReport inspects each node with stacks.
56+
// CheckAndReport inspects each node with stack.
5757
// It is implemented as the I/F of the "golang.org/x/tools/go/analysis/passes/inspect".Analysis.WithStack.
5858
func (s *Searcher) CheckAndReport(n ast.Node, push bool, stack []ast.Node) bool {
5959
id, insert, digg := s.Check(n, stack)
@@ -213,13 +213,15 @@ func (s *Searcher) innermostLoop(stack []ast.Node) (ast.Node, token.Pos) {
213213
return nil, token.NoPos
214214
}
215215

216+
// checkUnaryExpr check unary expression (i.e. <OPERATOR><VAR> like `-x`, `*p` or `&v`) and stack.
217+
// THIS IS THE ESSENTIAL PART OF THIS PARSER.
216218
func (s *Searcher) checkUnaryExpr(n *ast.UnaryExpr, stack []ast.Node) (*ast.Ident, token.Pos, bool) {
217-
loop, insert := s.innermostLoop(stack)
218-
if loop == nil {
219+
if n.Op != token.AND {
219220
return nil, token.NoPos, true
220221
}
221222

222-
if n.Op != token.AND {
223+
loop, insert := s.innermostLoop(stack)
224+
if loop == nil {
223225
return nil, token.NoPos, true
224226
}
225227

0 commit comments

Comments
 (0)