From: YenForYang Date: Fri, 17 Sep 2021 03:08:00 +0000 (-0500) Subject: lockWithDeferreds: inlineable Unlock() (#603) X-Git-Tag: v1.32.0~46 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=35ad29dcccd96768013a9e6344b8f716e86d1585;p=btrtrc.git lockWithDeferreds: inlineable Unlock() (#603) --- diff --git a/deferrwl.go b/deferrwl.go index e8e90e87..bf95be24 100644 --- a/deferrwl.go +++ b/deferrwl.go @@ -15,10 +15,11 @@ func (me *lockWithDeferreds) Lock() { } func (me *lockWithDeferreds) Unlock() { - for _, a := range me.unlockActions { - a() + unlockActions := me.unlockActions + for i := 0; i < len(unlockActions); i += 1 { + unlockActions[i]() } - me.unlockActions = me.unlockActions[:0] + me.unlockActions = unlockActions[:0] me.internal.Unlock() }