Skip to content

Commit

Permalink
Refactor inspect: pass set by value (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear authored Nov 23, 2023
1 parent d088c2c commit 903c0a7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions zerologlint.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ func run(pass *analysis.Pass) (interface{}, error) {
for _, b := range sf.Blocks {
for _, instr := range b.Instrs {
if c, ok := instr.(*ssa.Call); ok {
inspect(c, &set)
inspect(c, set)
} else if c, ok := instr.(*ssa.Defer); ok {
inspect(c, &set)
inspect(c, set)
}
}
}
Expand All @@ -61,7 +61,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
return nil, nil
}

func inspect(cd callDefer, set *map[posser]struct{}) {
func inspect(cd callDefer, set map[posser]struct{}) {
c := cd.Common()

// check if it's in github.com/rs/zerolog/log since there's some
Expand All @@ -70,7 +70,7 @@ func inspect(cd callDefer, set *map[posser]struct{}) {
if isInLogPkg(*c) || isLoggerRecv(*c) {
if isZerologEvent(c.Value) {
// this ssa block should be dispatched afterwards at some point
(*set)[cd] = struct{}{}
set[cd] = struct{}{}
return
}
}
Expand Down Expand Up @@ -118,10 +118,10 @@ func inspect(cd callDefer, set *map[posser]struct{}) {
// if there's branch, remove both ways from the set
if phi, ok := val.(*ssa.Phi); ok {
for _, edge := range phi.Edges {
delete(*set, edge)
delete(set, edge)
}
} else {
delete(*set, val)
delete(set, val)
}
}
}
Expand Down

0 comments on commit 903c0a7

Please sign in to comment.