Skip to content

Commit

Permalink
Merge pull request timakin#37 from scop/break-early
Browse files Browse the repository at this point in the history
Break/continue various loops earlier
  • Loading branch information
timakin authored Nov 25, 2022
2 parents c933b9a + 8431e02 commit e39cf3f
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 e39cf3f

Please sign in to comment.