Skip to content

Commit

Permalink
Merge pull request goplus#648 from aofei/sync
Browse files Browse the repository at this point in the history
perf(lib/sync): avoid using `defer`
  • Loading branch information
xushiwei authored Aug 3, 2024
2 parents 0bd2594 + d1f33a6 commit 8e0e809
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/lib/sync/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ type Once struct {
func (o *Once) Do(f func()) {
if !o.done {
o.m.Lock()
defer o.m.Unlock()
if !o.done {
o.done = true
f()
}
o.m.Unlock()
}
}

Expand Down

0 comments on commit 8e0e809

Please sign in to comment.