Skip to content

Commit

Permalink
Reduce lock scope (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktong authored Feb 29, 2024
1 parent bae986f commit b3ceed8
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ func (c Config) OnChange(onChange func(Config), paths ...string) {
return
}

c.values.onChangesMutex.Lock()
defer c.values.onChangesMutex.Unlock()

if len(paths) == 0 {
paths = []string{""}
}

c.values.onChangesMutex.Lock()
defer c.values.onChangesMutex.Unlock()

for _, path := range paths {
path = strings.ToLower(path)
c.values.onChanges[path] = append(c.values.onChanges[path], onChange)
Expand Down

0 comments on commit b3ceed8

Please sign in to comment.