perf(lib/sync): avoid using defer
This commit is contained in:
@@ -98,11 +98,11 @@ type Once struct {
|
|||||||
func (o *Once) Do(f func()) {
|
func (o *Once) Do(f func()) {
|
||||||
if !o.done {
|
if !o.done {
|
||||||
o.m.Lock()
|
o.m.Lock()
|
||||||
defer o.m.Unlock()
|
|
||||||
if !o.done {
|
if !o.done {
|
||||||
o.done = true
|
o.done = true
|
||||||
f()
|
f()
|
||||||
}
|
}
|
||||||
|
o.m.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user