Skip to content

Commit

Permalink
Break/continue various loops earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Mar 16, 2022
1 parent f498879 commit 8431e02
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions passes/bodyclose/bodyclose.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ func (r runner) run(pass *analysis.Pass) (interface{}, error) {
field := resStruct.Field(i)
if field.Id() == "Body" {
r.bodyObj = field

break
}
}
if r.bodyObj == nil {
Expand All @@ -75,21 +77,20 @@ func (r runner) run(pass *analysis.Pass) (interface{}, error) {
bmthd := bodyItrf.Method(i)
if bmthd.Id() == closeMethod {
r.closeMthd = bmthd

break
}
}

r.skipFile = map[*ast.File]bool{}
FuncLoop:
for _, f := range funcs {
// skip if the function is just referenced
var isreffunc bool
for i := 0; i < f.Signature.Results().Len(); i++ {
if f.Signature.Results().At(i).Type().String() == r.resTyp.String() {
isreffunc = true
continue FuncLoop
}
}
if isreffunc {
continue
}

for _, b := range f.Blocks {
for i := range b.Instrs {
Expand Down

0 comments on commit 8431e02

Please sign in to comment.