addCount should only be executed when there is data insertion

This commit is contained in:
shining-brain
2022-11-22 17:12:08 +08:00
committed by finley
parent 122d6ba505
commit f255fac7fb

View File

@@ -109,7 +109,6 @@ func (dict *ConcurrentDict) Put(key string, val interface{}) (result int) {
hashCode := fnv32(key)
index := dict.spread(hashCode)
s := dict.getShard(index)
dict.addCount()
s.mutex.Lock()
defer s.mutex.Unlock()
@@ -117,6 +116,7 @@ func (dict *ConcurrentDict) Put(key string, val interface{}) (result int) {
s.m[key] = val
return 0
}
dict.addCount()
s.m[key] = val
return 1
}