perf(lib/sync): avoid using defer

This commit is contained in:
Aofei Sheng
2024-08-03 09:04:34 +08:00
parent 0bd259403c
commit d1f33a6c4c

View File

@@ -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()
} }
} }