refactor: remove dup code

Signed-off-by: hyschumi<msliudongsheng@gmail.com>
This commit is contained in:
hyschumi 2021-11-04 21:11:53 +08:00 committed by liudongsheng
parent 2f21cff49d
commit da5d0a72d9

View File

@ -71,11 +71,7 @@ type threadSafeMap struct {
} }
func (c *threadSafeMap) Add(key string, obj interface{}) { func (c *threadSafeMap) Add(key string, obj interface{}) {
c.lock.Lock() c.Update(key, obj)
defer c.lock.Unlock()
oldObject := c.items[key]
c.items[key] = obj
c.updateIndices(oldObject, obj, key)
} }
func (c *threadSafeMap) Update(key string, obj interface{}) { func (c *threadSafeMap) Update(key string, obj interface{}) {