mirror of
https://github.com/FloatTech/ZeroBot-Plugin.git
synced 2025-12-20 22:40:23 +08:00
✏️ control 减少 defer 开销
This commit is contained in:
parent
2d69ae2e42
commit
350ef86dd6
@ -40,8 +40,8 @@ func newctrl(service string, o *Options) *Control {
|
|||||||
}(),
|
}(),
|
||||||
}
|
}
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
defer mu.Unlock()
|
|
||||||
managers[service] = m
|
managers[service] = m
|
||||||
|
mu.Unlock()
|
||||||
err := db.Create(service, &grpcfg{})
|
err := db.Create(service, &grpcfg{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@ -101,8 +101,8 @@ func (m *Control) Handler() zero.Rule {
|
|||||||
// not exist, it will returns nil.
|
// not exist, it will returns nil.
|
||||||
func Lookup(service string) (*Control, bool) {
|
func Lookup(service string) (*Control, bool) {
|
||||||
mu.RLock()
|
mu.RLock()
|
||||||
defer mu.RUnlock()
|
|
||||||
m, ok := managers[service]
|
m, ok := managers[service]
|
||||||
|
mu.RUnlock()
|
||||||
return m, ok
|
return m, ok
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user