Skip to content

Commit

Permalink
fix: data race fix (#64)
Browse files Browse the repository at this point in the history
resolves #63
  • Loading branch information
butuzov authored Oct 18, 2023
1 parent 8cb2f16 commit 2a0a6d2
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions analyzer/internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"regexp"
"sync"

"github.com/butuzov/ireturn/analyzer/internal/types"
)
Expand All @@ -13,16 +14,13 @@ type defaultConfig struct {
List []string

// private fields (for search optimization look ups)
init bool
once sync.Once
quick uint8
list []*regexp.Regexp
}

func (config *defaultConfig) Has(i types.IFace) bool {
if !config.init {
config.compileList()
config.init = true
}
config.once.Do(config.compileList)

if config.quick&uint8(i.Type) > 0 {
return true
Expand Down

0 comments on commit 2a0a6d2

Please sign in to comment.