Merge pull request #3055 from greatroar/cleanup

Don't separately allocate sync.{Mutex,Once} if not necessary
This commit is contained in:
Alexander Neumann 2020-11-04 11:11:21 +01:00 committed by GitHub
commit a06f5c28c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View file

@ -21,7 +21,7 @@ type LocalVss struct {
FS
snapshots map[string]VssSnapshot
failedSnapshots map[string]struct{}
mutex *sync.RWMutex
mutex sync.RWMutex
msgError ErrorHandler
msgMessage MessageHandler
}
@ -36,7 +36,6 @@ func NewLocalVss(msgError ErrorHandler, msgMessage MessageHandler) *LocalVss {
FS: Local{},
snapshots: make(map[string]VssSnapshot),
failedSnapshots: make(map[string]struct{}),
mutex: &sync.RWMutex{},
msgError: msgError,
msgMessage: msgMessage,
}

View file

@ -40,7 +40,7 @@ type Progress struct {
start time.Time
c *time.Ticker
cancel chan struct{}
o *sync.Once
once sync.Once
d time.Duration
lastUpdate time.Time
@ -79,7 +79,6 @@ func (p *Progress) Start() {
return
}
p.o = &sync.Once{}
p.cancel = make(chan struct{})
p.running = true
p.Reset()
@ -187,7 +186,7 @@ func (p *Progress) Done() {
}
p.running = false
p.o.Do(func() {
p.once.Do(func() {
close(p.cancel)
})