From 90986c1198d6da5bc89c0815fc2ab4ea1e7b8a0b Mon Sep 17 00:00:00 2001 From: rsteube Date: Thu, 7 Sep 2023 10:13:41 +0200 Subject: [PATCH] tmp --- storage.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/storage.go b/storage.go index 8e65de0b6..313e8bc60 100644 --- a/storage.go +++ b/storage.go @@ -29,20 +29,18 @@ type _storage map[*cobra.Command]*entry var storageMutex sync.RWMutex -func (s _storage) get(cmd *cobra.Command) (e *entry) { +func (s _storage) get(cmd *cobra.Command) *entry { storageMutex.RLock() + e, ok := s[cmd] + storageMutex.RUnlock() - var ok bool - if e, ok = s[cmd]; !ok { - storageMutex.RUnlock() + if !ok { storageMutex.Lock() defer storageMutex.Unlock() e = &entry{} s[cmd] = e - } else { - storageMutex.RUnlock() } - return + return e } var bridgeMutex sync.Mutex