From c81ee057ef59f1448a83b6c623c79cb0a3d63e13 Mon Sep 17 00:00:00 2001 From: Albert Teoh Date: Mon, 16 Dec 2024 22:07:11 +1100 Subject: [PATCH] Use standard lock --- util.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/util.go b/util.go index 2841f19..f15927a 100644 --- a/util.go +++ b/util.go @@ -7,7 +7,7 @@ import ( type SizeLimitedMap struct { ids map[string][]string size int - mu sync.RWMutex + mu sync.Mutex } func newSizeLimitedMap(size int) *SizeLimitedMap { @@ -35,8 +35,8 @@ func (sizeLimitedMap *SizeLimitedMap) add(key string, element string) { } func (sizeLimitedMap *SizeLimitedMap) contains(key string, element string) bool { - sizeLimitedMap.mu.RLock() - defer sizeLimitedMap.mu.RUnlock() + sizeLimitedMap.mu.Lock() + defer sizeLimitedMap.mu.Unlock() if val, ok := sizeLimitedMap.ids[key]; ok { for _, v := range val { @@ -50,8 +50,8 @@ func (sizeLimitedMap *SizeLimitedMap) contains(key string, element string) bool } func (sizeLimitedMap *SizeLimitedMap) count() int { - sizeLimitedMap.mu.RLock() - defer sizeLimitedMap.mu.RUnlock() + sizeLimitedMap.mu.Lock() + defer sizeLimitedMap.mu.Unlock() return len(sizeLimitedMap.ids) }